tags:

views:

22

answers:

1

I need to get previous 30 days from a specific date which is available from database(eg: 2010-05-23 12:36:29).I am try it by using

date('d', strtotime("-30 days"))

Which is getting the currect answer what i looking for but it is not help me to enter date from database.Please help me to solve the issue.

+4  A: 

Step by step:

$db_string =           "2010-05-23 12:36:26";
$db_timestamp =        strtotime($db_string);
$db_timestamp_30days = strtotime("-30 days", $db_timestamp);

$readable_date = date("d", $db_timestamp_30days);
Pekka
Thank you for your valuable information.Its working
Ajith
Just as an alternative, it is possible to use `strtotime` this way as well: `strtotime("2010-05-23 12:36:26 -30 days")`
Alexander Konstantinov