Greetings from Urdhva Tech!!
Several times I have came across same requirement of getting few days back from today, or few days after today. SugarCRM comes with few very handy date utility functions, and there is one which does the job!
$today = $timedate->getInstance()->nowDbDate(); // Today
$earlier = $timedate->asDbDate($timedate->getNow()->modify(“-30 days”)); // 30 days before!
$later = $timedate->asDbDate($timedate->getNow()->modify(“+2 months”)); // 2 months later!
echo “<br />30 days before:”.$earlier;
echo “<br />2 months later:”.$later;
Simple! Isn’t it?
Take a look at include/TimeDate.php for many other suitable date time functions.
Comments are welcome!
Follow us on Twitter @urdhvatech
Glimpse of our plug-ins & products.