Basically in my MySQL record database. There is a database field called “time” and that is set as Datetime.
$today = "";
$yesterday = "";
$currentmonth = "";
$lastmonth = "";
How do I get the following variables based on the Datetime(); the records appear with time like so (I was considering replacing the string after so many characters but speed is an issue?)
2011-11-10 11:59:45
2011-11-10 11:57:12
2011-11-10 11:55:29
2011-11-10 11:54:55
2011-11-10 11:54:21
You can try this :
$time = strtotime("2011-11-10 11:59:45");$day = date("d",$time);$month = date("m",$time);$year = date("Y",$time);You can use
date("d")+1 or date("d")-1to get day after tomorrow or yesterdays date. Same is the case for month and year.