Jump to content

Current Time and date


nclocl

Recommended Posts

I'm looking to enter the current time and date into a mysql database using php.  My current code looks like this:

 

$now = date("m/d/y",time());

 

I then insert $now into the table into a datetime column.  This all works but the time when read from the column appears as 0000-00-00 00:00:00.

 

Any ideas what I'm doing wrong?

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/245348-current-time-and-date/
Share on other sites

It's determined by the server, but you can specify a timezone for MySQL to run in to make things run a little smoother. Or you can handle timezones directly in PHP.

Check out the documentation on timezones for MySQL. I personally hate dealing with timezones, it makes things so complicated some times. Well, it makes them seem more complicated then they should. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.