Re: Dates - adding to unix 86400 seconds not equal nextday

From: Date: Thu, 02 Sep 2004 01:31:42 +0000
Subject: Re: Dates - adding to unix 86400 seconds not equal nextday
Groups: php.db 
Request: Send a blank email to php-db+get-36008@lists.php.net to get a copy of this message
I'd still like to find out if there is a mysql equivalent of gmmktime for use in queries like: "SELECT UNIX_TIMESTAMP(mydate) FROM MyTable WHERE UNIX_TIMESTAMP(mydate)<='$thisdate'"; and $thisdate is a gm date. Otherwise I need to convert the GMT date back to Summer time just for the query. Is there a function for that....?
There is, so I found. As John Holmes suggested, the use of date("I",$unixdate) was in order. $thisdate=$unixdate-3600*(date("I",$unixdate)); converts $thisdate to a unix number that will give the right date in a Summer time context - for use in the query. date("I") gives 1 where the $unixdate is in Summer time. The expression deducts an hour where the date would be in Summer time. So, I suppose 1am on 30 Oct becomes midnight on 30 October when evaluated as a date. And so it does, below. http://uk2.php.net/manual/en/function.gmdate.php $unixdate=mktime(1,0,0,10,30,2004); //1am on 30 Oct 2004 $thisdate=$unixdate-3600*(date("I",$unixdate)); $conv_date=date("l dS of F Y h:i:s A",$thisdate); print("<br>$conv_date"); //Saturday 30th of October 2004 12:00:00 AM =>Summer time as 1 hour deducted Good.

« previous php.db (#36008) next »