Skip to content

Date and Time

Dmitriy Zayceff edited this page Apr 30, 2015 · 7 revisions

There is a few classes to work with date, time and timezones:

Zend -> JPHP

  • DateTime -> Time, TimeZone
  • time -> Time::seconds() unix time in seconds (UTC), Time::now, Time::today
  • ??? -> Time::millis() unix time in milliseconds
  • microtime(1) -> Time::millis() / 1000
  • strtotime -> TimeFormat::parse
  • date -> TimeFormat::format

Examples

How to format a date

use php\time\Time;

$time = Time::now();
echo $time->toString('d-m-Y');

// or you can use TimeFormat 

$tf = new TimeFormat('d-m-Y');
echo $tf->format(Time::now());
Clone this wiki locally