Hi,
anybody knows server clock script to get time from server no need to refrsh the page as it will automatically uodated from script when time changes
from javascript its quite easy how to do from PHP to get server time
<script language="JavaScript">
function show(){
var Digital=new Date()
var hours=Digital.getHours()
var minutes=Digital.getMinutes()
if (hours<=9)
hours="0"+ hours
if (minutes<=9)
minutes="0"+minutes
document.tstest.clock.value=hours+":"+minutes
It's a little bit tough. You need to get the server time, check the offset from your current time, and use these numbers to adjust the javascript clock, using the Date object in javascript.
PHP Code:
<script language="JavaScript">
function calculate() {
var serhours = <?PHP echo date("g") ?>;
var serminutes = <?PHP echo date("i") ?>;
var Digital=new Date();
var hours=Digital.getHours();
var minutes=Digital.getMinutes();
if (hours<=9) {
hours="0"+ hours;
}
if (minutes<=9) {
minutes="0"+minutes;
}
var Digital=new Date();
var hours=Digital.getHours();
var minutes=Digital.getMinutes();
var serhrs = Number(hours) + Number(hrsdif);
var sermins = Number(minutes) + Number(mindif);
document.tstest.clock.value=serhrs+":"+sermins;
setTimeout("show()",1000);
}
when i am using this script as i want after 12Pm it shows 13,14 and so on but i have seen a strane thing for min.
its coming negative as 17:-1 and aftr this it become 17:0 and 17:1
Thanks ...i got one problem i created a colum called Nr and tryin to update everyime i mean to say autoincremented
$query = "SELECT id from key_generator where name = 't_emp'";
$pkResult = mysql_query($query) or die("Query failed: Get last Id");
$row = mysql_fetch_assoc($pkResult);
$pk = $row[id];
$pk++;$query = "SELECT id from key_generator where name = 't_emp'";
$pkResult = mysql_query($query) or die("Query failed: Get last Id");
$row = mysql_fetch_assoc($pkResult);
$pk = $row[id];
$pk++;
i just want to get value of pk from application but its unable to show the value
<?echo $_POST["pk"]; ?> //is anything wrong in this code
sorry its not working when i am using
$row = mysql_fetch_assoc($pkResult[0]);
and then try to print incremented value like this
<? echo mysql_fetch_assoc($pkResult)?>
its showing no value in cleint side and morever how i can give some name to this field as i need name to insert value in database
but when i try to use this on client side
<td><input size="1" type="text" name="nr" value="<?= $pk ?>" readonly></td>
its working fine and showing the result what i want but problem its taking too much space i mean to say size of field width
2-----this is $pk
001
yaa my Nr field have attribute unsigned Zerofill int(3)
<input type="button" class="button" value="Save" name="Save" border="1" onclick="go();">
this button submits this nr. value to database for that i need the name of this field,if i use <? echo ($pk) ?> where should i give field name so that it will be helpful for insértion otherwise querry error.
but when i use ><input size="1" type="text" name="nr" value="<?= $pk ?>" readonly></td>
then its working fine only problem its taking space
even though i remove zerofill how i can get name for this field
<?echo ($nr); ?>the problem is how to get field name not zerofill even if not remove this value is printing
i got another problem with below script
<td nowrap>
<input type="text" class="button" size="1" name="clock">
<select name="To" size="1" onChange="calculateIst()">
<option selected value="<?=date('H:i')?>"><? echo (date('H:i')); ?></option>
<? fillDD(8, 0, -1); ?>
</select>
</td>
<td>
<? if ($_POST["To"] != "clock") {?>
<?= $line["To"] ?>
<? if (isset($_POST["clock"]))?>//its not going to this loop
<?echo $_POST["clock"]; ?>
<? }?>
</td>
its getting only value of To field no matter whether user chooses tiem from To or running clock is there,i want something like when user not select anything from To he will get value of clock and if i use this alone
<? if (isset($_POST["clock"]))?>//getting error
<?echo $_POST["clock"]; ?>
<? }?>
Bookmarks