Forum Moderators: coopster

Message Too Old, No Replies

strtotime

strtotime

         

chrissim

11:43 pm on Jun 1, 2010 (gmt 0)

10+ Year Member


hi,

The coding below using strtotime were based on today date but how do you construct the strtotime based on yesterday date, hour: minutes: second with these coding?

strtotime(date("Y-m-d")." 00:00:00")

Matthew1980

7:02 am on Jun 2, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi there Chrissim,

Well, easy answer to your question:-

echo date("Y-m-d", strtotime("-1 day"));

that should print the date based on today - but back 1 day, you use strtotime() as an offset.

Cheers,
MRb

chrissim

10:05 am on Jun 2, 2010 (gmt 0)

10+ Year Member



hi Matthew1980.

Yes i know this i can use them as you suggested but only if i have a date in my tanle field. But the problem was that i have a timestamp in my table that generated eg 1275472779 and it is impossible to retrieve my data

chrissim

10:17 am on Jun 2, 2010 (gmt 0)

10+ Year Member



hi,

nevermind i got it now. strtotime("-1 day 00:00:00");
Thanks

penders

6:35 pm on Jun 2, 2010 (gmt 0)

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



FYI... strtotime() [uk3.php.net] can take a 2nd argument, a unix timestamp, on which to base relative dates.