note 13158 deleted from function.strtotime by jimw

From: Date: Fri, 14 Dec 2001 20:57:15 +0000
Subject: note 13158 deleted from function.strtotime by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22797@lists.php.net to get a copy of this message
strtotime() is different on PHP for Windows and Linux. The first section of the following code report correct result on PHP for Windows (given day + 30 days) while it need to be rewritten on PHP for Linux. Here is a list of sample code for your reference. <html><head><title></title></head><body bgcolor="#FFFFCC"> <? $given_date = "2001-05-01"; echo "<p>given_day = <font color=\"#FF0000\">$given_date </font></p>"; $after_30days = date("Ymd", strtotime($given_date) + 2592000); echo "<p>strtotime() works on PHP for Windows not Linux.<br> <font color=\"#FF0000\"> after_30days = $after_30days</font></p>"; $temp = substr($given_date,5,2)."/".substr($given_date,8,2)."/".substr($given_date,0,4); echo "<p>On Linux, you need to transform date format into <br> <font color=\"#FF0000\">[$temp]</font></p>"; $after_30days = date("Ymd", strtotime($temp) + 2592000); echo "<p>Now, strtotime() works on Windows and Linux. <br> <font color=\"#FF0000\"> after_30days = $after_30days</font></p>"; ?> </body></html> If you have any questions, please don't hastitate to ask me.

« previous php.notes (#22797) next »