27
May

0 Comments | 0 Shares | Urdhva Tech | Tags: Datetime

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!

 


global $timedate;
$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 "Today:".$today; 
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!

Download attachments:
Comments
  • No Comments Found.
Post your comment