This is a discussion on "Update Date/Time Button" within the JavaScript Forum section. This forum, and the thread "Update Date/Time Button are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
Update Date/Time Button
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
Update Date/Time Button
I am wanting to use the server time, or a specific time zone (-5 GMT) to have the update date/time button refer to. Right now this script references the users local time when they click the update date/time button.
My problem is simply that I have many users in different time zones, and when they update an entry, it doesn't make any logical sense to the other time zones. So to make it logical, if they are seeing the same time it can be related to one another. Thank you for any help! <html> <head> <script language="jscript" type=""> function setcompleted() { var myDate = new Date(); var str = (myDate.getMonth()+1) + "/" + pad(myDate.getDate()) + "/" + myDate.getFullYear(); str += " " + pad(myDate.getHours()) + ":" + pad(myDate.getMinutes()); document.forms[0].date_time.value=str; } function pad(num) { if (num < 10) return "0" + num; else return num; } </script> </head> <body> <form> <input type="text" value="_currentdatetime" name="date_time" required="false"></input> <button language="jscript" onClick="return setcompleted()">Update Date/Time</button> </form> </body> </html> |
|
|
|
|||
|
Re: Update Date/Time Button
The javascript you are using is asking the users' computer what its internal date/time is. This is why all of the times appear different when your users post from different time zones.
If your site is made in PHP or ASP and is capable of using SSI (server-side includes), you might find this article useful: http://www.dynamicdrive.com/dynamicindex6/localtime.htm You might also try this javascript that I found here: http://javascript.internet.com/time-...avascript.html
I hope this helps. |
![]() |
| Tags |
| date, form, server time, time, update |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Date & Time [Combine] | doctypedeclaration | JavaScript Forum | 3 | Mar 12th, 2008 01:22 |
| Can't open the date time picker | yuenli | JavaScript Forum | 0 | Jul 3rd, 2007 07:22 |
| Access date field - update as record is updated | matrixbrawl | Databases | 0 | Jan 10th, 2007 09:58 |
| Creating Date & Time | SweetLou | Classic ASP | 1 | Jan 23rd, 2006 13:55 |
| Server time and date script | gribble | JavaScript Forum | 1 | Aug 16th, 2005 09:53 |