PHP

HOW TO FORMAT UNIX TIMESTAMP TO DATE-TIME IN PHP

ISO 8601 $iso = date(DateTimeInterface::ATOM, $unix); COOKIE $cookie = date(DateTimeInterface:: COOKIE, $unix);

PREDEFINED DATE FORMATS

01

EMAIL (RFC 2822) $mail = date(DateTimeInterface:: RFC2822, $unix); HTTP 1.1 (RFC 7231) $http = date(DateTimeInterface:: RFC7231, $unix);

MYSQL $mysql = date("Y-m-d H:i:s", $unix);   CUSTOM DATE FORMATS $customA = date("d/m/y H:i:s", $unix); $customB = date("D, j F Y h:i:s A", $unix);

MANUAL DATE FORMATS

02

NEW DATE-TIME OBJECT $tz = new DateTime(); $tz->setTimestamp($unix);   CHANGE TIMEZONE $tz->setTimezone(new DateTimeZone('Asia/Tokyo')); echo $tz->format("Y-m-d H:i:s e");

SET THE TIMEZONE

03