Hi all.
I am grabbing two time stamps from a mysql db and storing them in variables, the timestamps are stored in the format YY-MM-DD HH:MM:SS .
Could anyone tell me how I might go about comparing two timestamps that are in this format, I need to check if one is older than the other.
Thank you for your time.
Compare two timestamps
Page 1 of 13 Replies - 409 Views - Last Post: 16 March 2013 - 01:41 PM
Replies To: Compare two timestamps
#2
Re: Compare two timestamps
Posted 16 March 2013 - 01:33 PM
It depends: what are the field data-types? Are they stored as strings or DATETIME (I assume) or TIMESTAMP?
#3
Re: Compare two timestamps
Posted 16 March 2013 - 01:35 PM
#4
Re: Compare two timestamps
Posted 16 March 2013 - 01:41 PM
If they are DATETIME (or TIMESTAMP) fields then it is more efficient to only retrieve the dated-records that you need, in the SQL statement:
..but if you need them as dates in the PHP then you might use strtotime() to convert them, having retrieved the values from the database. discussed here
Of course, this being PHP
, there are a dozen other ways to approach this.
WHERE date1 < date2
..but if you need them as dates in the PHP then you might use strtotime() to convert them, having retrieved the values from the database. discussed here
Of course, this being PHP
This post has been edited by andrewsw: 16 March 2013 - 01:38 PM
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|