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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux