Creating and comparing date/time, preferred format?
Moderator: General Moderators
- JAB Creations
- DevNet Resident
- Posts: 2341
- Joined: Thu Jan 13, 2005 6:44 pm
- Location: Sarasota Florida
- Contact:
Creating and comparing date/time, preferred format?
In regards to comparing date/time what format is best to use to compare two sets of date/time? I was reading something about Unix formatted time stamps on php.net and then found some reading on the Unix Epoch...I'm not really sure what would be the most proper/long term solution I should use though?
Re: Creating and comparing date/time, preferred format?
It's really just personal preference. Dates as numbers (eg, 1258322483) can be compared to other numbers just as easily as dates as strings (eg, "2009-11-15 14:01:23") can be compared to other strings.
However, since the end product is most often a string, numbers are easier to deal with because there's only one conversion. With strings they get converted to numbers and then back to strings: except for MySQL which can reformat a date string in one step... but that means doing the conversion in the SQL. All in all, numbers are easier to deal with in PHP but strings are easier in MySQL.
However, since the end product is most often a string, numbers are easier to deal with because there's only one conversion. With strings they get converted to numbers and then back to strings: except for MySQL which can reformat a date string in one step... but that means doing the conversion in the SQL. All in all, numbers are easier to deal with in PHP but strings are easier in MySQL.