note 68156 deleted from function.strtotime by derick

From: Date: Sun, 15 Jul 2007 12:38:44 +0000
Subject: note 68156 deleted from function.strtotime by derick
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-128553@lists.php.net to get a copy of this message
Note Submitter: news at mycoolstuff dot de ---- Be careful if you use combined JavaScript and PHP with strtotime you have to keep in mind, that you may get different timestamps. The following code will generate the same timestaps: <?php echo strtotime("2006-07-31 02:00:00"); ?> <script type="text/javascript"> document.writeln(Date.UTC(2006, 06, 31, 0, 0, 0)); </script> First you have to notice, that the Javascript Date.UTC function starts months counting with 0, not with 1 (for january) - this is documented well. But what I did not know and took me some time to find out is that you need to modify the time in strtotime() (for me it's 2 hours more than the JavaScript time). This maybe has something to do with GMT on local server, but I have no idea, so if you should know the reason why, please let me know. [Red.: This is because javascript returns UTC]

« previous php.notes (#128553) next »