What is the shortest way to replace date in 'yyyy-mm-dd hh:ii:ss'
format with 'yyyy-mm-05 hh:ii:ss'
?
I need to change the date days, not to subtract several days from the date.
Thank you.
$date = '2012-06-08 11:15:00';
echo date('Y-m-05 H:i:s', strtotime($date)); // 2012-06-05 23:15:00
You can go with:
$dt = new DateTime('2012-06-08 12:00:00');
$dt->setDate($dt->format('Y'), $dt->format('m'), 5);
echo $dt->format('Y-m-d H:i:s');
Maybe not the shortest, but it's a solid approach
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With