|
|||||||
| PHP Discussion and technical support for using and deploying PHP based websites. |
![]() |
|
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
server clock
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 setTimeout("show()",1000) } show() </script> <input type="text" class="button" size="1" name="clock"> how to get from PHP. Thanks
__________________
arun krishnan |
|
#2
|
||||
|
||||
|
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:
__________________
Personal website http://www.ryanbrill.com/ Business website: http://www.infinitywebdesign.com/ TypeSpace http://www.typespace.org/ I reject your reality and substitute it with my own! |
|
#3
|
|||
|
|||
|
thanks once again but one problem when i am trying to retrieve the value
<? if ($_POST["clock"] ) {?> <?// what shoulid i write to get this server clock value?> <? }?> for eg.<? echo() ?>
__________________
arun krishnan |
|
#4
|
||||
|
||||
|
PHP Code:
__________________
Personal website http://www.ryanbrill.com/ Business website: http://www.infinitywebdesign.com/ TypeSpace http://www.typespace.org/ I reject your reality and substitute it with my own! |
|
#5
|
|||
|
|||
|
function calculate() {
var serhours = <?PHP echo date("H") ?>; 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; } hrsdif = serhours - hours; mindif = serminutes - minutes; show(); } function show() { 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 how to over coem this
__________________
arun krishnan |
|
#6
|
||||
|
||||
|
Change function show() to something like this:
Code:
function show() {
var Digital=new Date();
var hours=Digital.getHours();
var minutes=Digital.getMinutes();
var serhrs = Number(hours) + Number(hrsdif);
var sermins = Number(minutes) + Number(mindif);
if (serhrs < 0) {
serhrs = 00;
}
if (sermins < 0) {
sermins = 00;
}
document.tstest.clock.value=serhrs+":"+sermins;
setInterval("show()",1000);
}
__________________
Personal website http://www.ryanbrill.com/ Business website: http://www.infinitywebdesign.com/ TypeSpace http://www.typespace.org/ I reject your reality and substitute it with my own! |
|
#7
|
|||
|
|||
|
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 thanks in advance
__________________
arun krishnan |
|
#8
|
||||
|
||||
|
$pkResults is an array. Try this:
PHP Code:
__________________
Personal website http://www.ryanbrill.com/ Business website: http://www.infinitywebdesign.com/ TypeSpace http://www.typespace.org/ I reject your reality and substitute it with my own! |
|
#9
|
|||
|
|||
|
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 thanks in advance
__________________
arun krishnan |
|
#10
|
||||
|
||||
|
Does you id row have the unsigned zerofill attribute set?
__________________
Personal website http://www.ryanbrill.com/ Business website: http://www.infinitywebdesign.com/ TypeSpace http://www.typespace.org/ I reject your reality and substitute it with my own! |
|
#11
|
|||
|
|||
|
hi,
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 thanks in advance
__________________
arun krishnan |
|
#12
|
||||
|
||||
|
With zerofill, it will pad the number with 0's. Just remove that, and you should get numbers like 1,2,3 rather than 001,002,003...
__________________
Personal website http://www.ryanbrill.com/ Business website: http://www.infinitywebdesign.com/ TypeSpace http://www.typespace.org/ I reject your reality and substitute it with my own! |
|
#13
|
|||
|
|||
|
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"]; ?> <? }?> how to overcome this problem
__________________
arun krishnan |
|
#14
|
|||
|
|||
|
hi,
<?echo ($nr); ?> how to give name something like name='nr' in this tag as name is needed for insertion in database. thanks
__________________
arun krishnan |
|
#15
|
||||
|
||||
|
huh?
Is this what you mean? PHP Code:
__________________
Personal website http://www.ryanbrill.com/ Business website: http://www.infinitywebdesign.com/ TypeSpace http://www.typespace.org/ I reject your reality and substitute it with my own! |
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|