Forum Moderators: coopster

Message Too Old, No Replies

understanding mysql timestamp

do I have this right?

         

HelenDev

9:22 am on Jul 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



if I have this timestamp...

20040713131003

...does it mean this...

2004//year

07//month

13//day

13.10.03 //time

...or do I have it muddled?

charlier

9:23 am on Jul 16, 2004 (gmt 0)

10+ Year Member



Thats correct.

HelenDev

9:45 am on Jul 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks Charlier :)

As I understand it this is a different format to the Unix timestamp which I can capture with php?

Basically what I want to do is capture the current date and then select only records added in the last month. Can anyone give me any tips?

charlier

11:15 am on Jul 16, 2004 (gmt 0)

10+ Year Member



You can use the mysql timestamp for that just do a select with a where clause:

WHERE MyDate LIKE '200407%'

if you need to figure out what the current year month is you can use the php functions getdate and time. For example

$today = getdate(time());
and then you would get your month and year from

$Mon = $today[mon];
$Year = $today[year];

just have to watch the $Mon as I think the php function returns 1-12 not 01-12 so you have to put a 0 before the <10 months.

HelenDev

12:06 pm on Jul 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks again charlier.

So this would get everything in the present calendar month. If I wanted to select everything from the last 30 days however, is there a function I can use to rewind the date by 30 days or will I have to do some maths?

ergophobe

3:06 pm on Jul 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Check out the Mysql Date and Time Functions [dev.mysql.com]

Tom