FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » MySQL date time current time diffenece
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
MySQL date time current time diffenece [message #175188] Sun, 21 August 2011 13:42 Go to previous message
j is currently offline  j
Messages: 9
Registered: July 2011
Karma:
Junior Member
I have a timestamp in MySQL table. I want to compare that to the
current time. I'll be using this code on different servers.

I can do this:

$mysql_datetime = '2011-08-19 14:00:35';

$mysql_datetime_formatted = preg_replace('/\D/','',$mysql_datetime);

$date_now = date("YmdHis");

$diff = $date_now - $mysql_datetime_formatted;

echo "$mysql_datetime_formatted - $date_now = $diff in seconds";

Can I count on (more or less) the MySQL time/time zone to be the same as
that PHP uses?

More reliable or easier way?

Jeff
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Webhosting, Domain Name, Data Center Cyprus, Hosting Services
Next Topic: Roll SQL name value query into two-dimensional array
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Thu Nov 28 22:54:53 GMT 2024

Total time taken to generate the page: 0.05903 seconds