|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Compare timeStamps
I would like to compare two timestamps that are in a MySQL db.
The reason I have 2 timestamps, is because one updates to NOW when the page is loaded. Before the timeStamp goes threw $dateFormat, it looks like this, if that helps any. 20030731112209 The function that I used doesn't seem to work correctly. Tables as follows: articleDate timestamp(14) NOT NULL, timestampNow timestamp(14) NOT NULL, PHP Code:
Page outputs: Now: <? echo $row->timestampNow; ?><br> Date Posted: <? echo $row->articleDate; ?><br> Article is <? echo thatDate(('articleDate')); ?> old. The results that I'm getting. Now: Thursday July 31st, 2003 - 12:58:48 PM Date Posted: Thursday July 31st, 2003 - 12:53:17 PM Article is 1d 20h 59m old. <-- Wrong |
|
#2
|
||||
|
||||
|
Consider using int(11) as your time field and inserting time() from PHP. Then you can use FROM_UNIXTIME() and DATE_FORMAT(FROM_UNIXTIME(),'format') to extract readable dates while also making the math easy. Note that the timestamp field prepends the year, month, and day to the seconds string, so any math you do on that unconverted number is going to come out pretty funky.
|
|
#3
|
|||
|
|||
|
Thanks dhouston,
I wil convert my times, and try again. If I still seem to have problems, I will post back, thanks again |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Compare timeStamps |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|