note 52227 added to function.time
| From: | alex at osu1 dot php dot net | Date: | Mon, 25 Apr 2005 07:39:05 +0000 |
| Subject: | note 52227 added to function.time | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-88515@lists.php.net to get a copy of this message | ||
sorry, quick correction on previous post
JavaScript's getTime() actually uses GMT, you must incorporate the getTimezoneOffset() in order
to make it any different then PHP's time().
like so:
<script language="JavaScript">
function addTime() {
var d = new Date();
var TI = document.getElementById('time');
TI.value=Math.floor(d.getTime()/1000)-(d.getTimezoneOffset()*60);
}
</script>
simply set that function as the onsubmit of any form the has a hidden <input> with
id="time" any you're golden. getTimezoneOffset gives the offset difference in
minutes, hence the *60. I hope this is of assistance to someone.
----
Manual Page -- http://www.php.net/manual/en/function.time.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+52227
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52227&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52227&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52227&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52227&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52227&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+52227&report=yes
Search -- http://master.php.net/manage/user-notes.php