Reputation: 18029
I want to get the unix time stamp for that day exactly 30days back from current day. What is the best method?
Can i use this to get the date 30 days back, is this the best method?
$day = date('Y-m-d', strtotime('-30 days'));
a google search brings me to mktime()
function in php. But how do i combine both and get the unix time stamp for the day? What is the easiest and fastest method?
Upvotes: 3
Views: 5082
Reputation: 11215
How to get previous month and year relative to today, using strtotime and date? watch this question. there is the discussion about the funny strtotime("-1 month");
bug.
Upvotes: 0
Reputation: 16944
$date = date_create();
date_sub($date, date_interval_create_from_date_string('1 m'));
echo date_format($date, 'U');
Upvotes: 1
Reputation: 6965
You just need to use the strtotime("-1 month");
function. That will return a UNIX timestamp.
Upvotes: 3