So if today was April 12, 2010 it should return October 1, 2009
Some possible solutions I've googled seem overly complex, any suggestions?
You can be creative with this. For example, to get the first and last second of a month: $timestamp = strtotime('February 2012'); $first_second = date('m-01-Y 00:00:00', $timestamp); $last_second = date('m-t-Y 12:59:59', $timestamp); // A leap year!
Get Last Day Of The Previous Month:$lastDay = date('t',strtotime('last month')); print_r($lastDay);
php $m = date("m"); // Month value $de = date("d"); // Today's date $y = date("Y"); // Year value echo "Yesterday's date was: " . date('d-m-Y', mktime(0,0,0,$m,($de-1),$y)); ?>
if (strtotime($date) > mktime(0,0,0)) should do the job.
Hm, maybe something like this;
echo date("F 1, Y", strtotime("-6 months"));
EDIT;
if you would like to specify a custom date use;
echo date("F, 1 Y", strtotime("-6 months", strtotime("Feb 2, 2010")));
A bit hackish but works:
<?php $date = new DateTime("-6 months"); $date->modify("-" . ($date->format('j')-1) . " days"); echo $date->format('j, F Y'); ?>
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