This topic is locked

How can I display the date/time from current user's system

11/29/2006 1:51:08 AM
PHPRunner General questions
Q
Quizosde author

i would love some help with this, i'm very confused....
I have a DATETIME field, and on my add record page I have that input field processed as a 'Date' with the simple edit box with datepicker option.
When the page loads I would like the current time and date on the user's machine to be entered into the box. I started out just by putting now() as the default value, but the clock was 2 hours off, in MST, when it should be in EST.
I've been trying to figure this out on my own and am going in circles between mysql and php parameters...
Anyhelp would be greatly appreacited!!

Thanks

J
Jane 11/29/2006

Hi,
you can do it using JavaScript.

Proceed to the Visual Editor tab, turn on HTML mode, find this line:

<!-- legend -->



and add the following code just after:

<script>

var t = new Date();

editform.value_OrderDate.value = ""+t.getDate()+"/"+(t.getMonth()+1)+"/"+t.getFullYear()+" "+t.getHours()+":"+t.getMinutes()+":"+t.getSeconds();

</script>

Q
Quizosde author 11/30/2006

Thank you for the response, but I still seem to be having trouble. Using the Javascript code, I still wasn't able to correct for the 2 hour timezone difference, and I still wasn't able to put that data in my datetime field. Using your method, the date input box just spit out "01/00/0", the same result as if I put date("m/d/Y h:i a") as the default value. If I changed the input type to a text area, the date would display with the given parameters, however.
So I think its something to do with how phprunner and how it processes the timestamp it gets when you have a datetime field and use the date option as the input.
So using the date option input type, I can only ever get it to show the date by using now(), and then I don't know how to change the format and don't know how to compensate for a different timezone.

J
Jane 12/1/2006

This code works for me.

Make sure you put code to the correct place.
If this doesn't help send templates/..._add.htm file to [email=support@xlinesoft.com]support@xlinesoft.com[/email].