Common ###### .. highlight:: php Date Object =========== The ``Date`` object is immutable. Internally it only contains the set Julian day integer. The ``Calendar`` class contains factories for the Gregorian calendar and DateTime interoperability. Arithmetic ---------- You can add or subtract days:: add(100); // 2013-03-31, 100 days after the apocalypse echo $date->subDays(100); // 2012-09-12 // = echo $date->add(-100); $today = Date::today(); // days since the apocalypse :D echo $today->sub($date); // 4085 as of Feb 27, 2024 Calendar Agnostic Methods ========================= Today ----- Gets a current date for the default or specific time zone:: getWeekDay(); // like WeekDay::Tuesday $date->getWeekDayNumber(); // 2 == WeekDay::Tuesday->value DateTime Interoperability ========================= Import/Export date from DateTime objects. Import ------ Create an instance of Date from an instance of DateTimeInterface or by using DateTime's own parser:: toDateTime(); // timestamp at given date midnight system time $date->toDateTime(new DateTimeZone('Asia/Tokyo')); // timestamp at given date midnight Tokyo Also a formatter shortcut is available:: formatDateTime('m/d/y'); // equivalent to $date->getDateTime()->format('m/d/y'); // note that it can handle ISO week date too: $date->formatDateTime('o-\\WW-N');