Jump to content

PHP Date-Time to SQL Date-Time and vice versa?


scott.stephan

Recommended Posts

In the current app I'm working on, there are a lot of functions that use dates and time to trigger certain actions. I like PHP DATE stuff because you can perform easy arithmetic on it. I like SQL DATETIME because you can store all of your time data in one chunk instead of having order_hour, order_minute, order_day, order_month etc. etc,.

 

What I'm a little unsure of is how PHP and SQL are going to play along when it comes to dates. Honestly, it seems like it may be a pain to pull a date from SQL and parse it into usable pieces. Does anyone have a guide or an article on the challenges of swapping between SQL and PHP with regards to DATE/TIME stuff?

Mysql has a large number of built-in date and time functions, which are more useful and capable than what php currently has, that make using php code unnecessary for most tasks (and php code to accomplish the same task is also several times slower.)

 

Ref: http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html

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.