<?php
$date_object = new DateTime('2011-04-24');
echo
"Today: ".date('Y-m-d').PHP_EOL.
"Yesterday: ".date('Y-m-d', mktime(0, 0, 0, date("m"), date("d")-1, date("Y"))).PHP_EOL.
"42 days ago: ".date('Y-m-d', mktime(0, 0, 0, date("m"), date("d")-42, date("Y"))).PHP_EOL.
"OP's date: ".date('Y-m-d', mktime(0, 0, 0,
$date_object->format("m"),
$date_object->format("d")-1,
$date_object->format("Y")
)
);
preferences:
57.48 ms | 405 KiB | 5 Q