Date and Time helper for PHP (like Joda-Time in Java)

I am looking for a library (open source) like Joda-Time in the Java world. Is there any library like that?

Joda-Time is very helpful to calculate date and time. I can add days, weeks, month, year and also can converting date and time easily.

I wish there is library like Joda-Time for PHP.

Edit: I need some functions that available in Joda-Time like daysBetween (to calculate number of days between 2 date), monthsBetween and weeksBetween ... Some functions about add and substract date is available from PHP itself.

This question and answers originated from www.stackoverflow.com
Question by (8/25/2009 3:06:06 AM)

Answer

There is no need for external library. PHP is more than capable of this already.

<?php
/** These examples work with the current time **/
echo strtotime("now"), "\n";
echo strtotime("10 September 2000"), "\n";
echo strtotime("+1 day"), "\n";
echo strtotime("+1 week"), "\n";
echo strtotime("+1 week 2 days 4 hours 2 seconds"), "\n";
echo strtotime("next Thursday"), "\n";
echo strtotime("last Monday"), "\n";

/** This is a made up time **/
$lessMonth = strtotime("06/19/1986 3:00PM")
$lessMonth = strtotime("-1 month", $lessMonth);

echo $lessMonth, "\n";
echo gmdate('c', $lessMonth);

/** 86 400 seconds in a day */
$daysBetween = (strtotime("now") - $lessMonth) / 86400
?>
Answer by

Find More Answers
Related Topics  java  php  datetime  date  jodatime
Related Questions