Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Format a Unix timestamp
<?php date(string $format, ?int $timestamp = null): string
<?php self::assertNotFalse($row);
$row = array_change_key_case($row, CASE_LOWER);
self::assertEquals('2010-01-01 10:10:11', date('Y-m-d H:i:s', strtotime($row['add_seconds'])));
self::assertEquals('2010-01-01 10:10:09', date('Y-m-d H:i:s', strtotime($row['sub_seconds'])));
self::assertEquals('2010-01-01 10:15:10', date('Y-m-d H:i:s', strtotime($row['add_minutes'])));
self::assertEquals('2010-01-01 10:05:10', date('Y-m-d H:i:s', strtotime($row['sub_minutes'])));
<?php $row = array_change_key_case($row, CASE_LOWER);
self::assertEquals('2010-01-01 10:10:11', date('Y-m-d H:i:s', strtotime($row['add_seconds'])));
self::assertEquals('2010-01-01 10:10:09', date('Y-m-d H:i:s', strtotime($row['sub_seconds'])));
self::assertEquals('2010-01-01 10:15:10', date('Y-m-d H:i:s', strtotime($row['add_minutes'])));
self::assertEquals('2010-01-01 10:05:10', date('Y-m-d H:i:s', strtotime($row['sub_minutes'])));
self::assertEquals('2010-01-01 13:10', date('Y-m-d H:i', strtotime($row['add_hour'])));
<?php self::assertEquals('2010-01-01 10:10:11', date('Y-m-d H:i:s', strtotime($row['add_seconds'])));
self::assertEquals('2010-01-01 10:10:09', date('Y-m-d H:i:s', strtotime($row['sub_seconds'])));
self::assertEquals('2010-01-01 10:15:10', date('Y-m-d H:i:s', strtotime($row['add_minutes'])));
self::assertEquals('2010-01-01 10:05:10', date('Y-m-d H:i:s', strtotime($row['sub_minutes'])));
self::assertEquals('2010-01-01 13:10', date('Y-m-d H:i', strtotime($row['add_hour'])));
self::assertEquals('2010-01-01 07:10', date('Y-m-d H:i', strtotime($row['sub_hour'])));
<?php self::assertEquals('2010-01-01 10:10:11', date('Y-m-d H:i:s', strtotime($row['add_seconds'])));
self::assertEquals('2010-01-01 10:10:09', date('Y-m-d H:i:s', strtotime($row['sub_seconds'])));
self::assertEquals('2010-01-01 10:15:10', date('Y-m-d H:i:s', strtotime($row['add_minutes'])));
self::assertEquals('2010-01-01 10:05:10', date('Y-m-d H:i:s', strtotime($row['sub_minutes'])));
self::assertEquals('2010-01-01 13:10', date('Y-m-d H:i', strtotime($row['add_hour'])));
self::assertEquals('2010-01-01 07:10', date('Y-m-d H:i', strtotime($row['sub_hour'])));
self::assertEquals('2010-01-11', date('Y-m-d', strtotime($row['add_days'])));
<?php self::assertEquals('2010-01-01 10:10:09', date('Y-m-d H:i:s', strtotime($row['sub_seconds'])));
self::assertEquals('2010-01-01 10:15:10', date('Y-m-d H:i:s', strtotime($row['add_minutes'])));
self::assertEquals('2010-01-01 10:05:10', date('Y-m-d H:i:s', strtotime($row['sub_minutes'])));
self::assertEquals('2010-01-01 13:10', date('Y-m-d H:i', strtotime($row['add_hour'])));
self::assertEquals('2010-01-01 07:10', date('Y-m-d H:i', strtotime($row['sub_hour'])));
self::assertEquals('2010-01-11', date('Y-m-d', strtotime($row['add_days'])));
self::assertEquals('2009-12-22', date('Y-m-d', strtotime($row['sub_days'])));
<?php self::assertEquals('2010-01-01 10:15:10', date('Y-m-d H:i:s', strtotime($row['add_minutes'])));
self::assertEquals('2010-01-01 10:05:10', date('Y-m-d H:i:s', strtotime($row['sub_minutes'])));
self::assertEquals('2010-01-01 13:10', date('Y-m-d H:i', strtotime($row['add_hour'])));
self::assertEquals('2010-01-01 07:10', date('Y-m-d H:i', strtotime($row['sub_hour'])));
self::assertEquals('2010-01-11', date('Y-m-d', strtotime($row['add_days'])));
self::assertEquals('2009-12-22', date('Y-m-d', strtotime($row['sub_days'])));
self::assertEquals('2010-01-08', date('Y-m-d', strtotime($row['add_weeks'])));
<?php self::assertEquals('2010-01-01 10:05:10', date('Y-m-d H:i:s', strtotime($row['sub_minutes'])));
self::assertEquals('2010-01-01 13:10', date('Y-m-d H:i', strtotime($row['add_hour'])));
self::assertEquals('2010-01-01 07:10', date('Y-m-d H:i', strtotime($row['sub_hour'])));
self::assertEquals('2010-01-11', date('Y-m-d', strtotime($row['add_days'])));
self::assertEquals('2009-12-22', date('Y-m-d', strtotime($row['sub_days'])));
self::assertEquals('2010-01-08', date('Y-m-d', strtotime($row['add_weeks'])));
self::assertEquals('2009-12-25', date('Y-m-d', strtotime($row['sub_weeks'])));
<?php self::assertEquals('2010-01-01 13:10', date('Y-m-d H:i', strtotime($row['add_hour'])));
self::assertEquals('2010-01-01 07:10', date('Y-m-d H:i', strtotime($row['sub_hour'])));
self::assertEquals('2010-01-11', date('Y-m-d', strtotime($row['add_days'])));
self::assertEquals('2009-12-22', date('Y-m-d', strtotime($row['sub_days'])));
self::assertEquals('2010-01-08', date('Y-m-d', strtotime($row['add_weeks'])));
self::assertEquals('2009-12-25', date('Y-m-d', strtotime($row['sub_weeks'])));
self::assertEquals('2010-03-01', date('Y-m-d', strtotime($row['add_month'])));
<?php self::assertEquals('2010-01-01 07:10', date('Y-m-d H:i', strtotime($row['sub_hour'])));
self::assertEquals('2010-01-11', date('Y-m-d', strtotime($row['add_days'])));
self::assertEquals('2009-12-22', date('Y-m-d', strtotime($row['sub_days'])));
self::assertEquals('2010-01-08', date('Y-m-d', strtotime($row['add_weeks'])));
self::assertEquals('2009-12-25', date('Y-m-d', strtotime($row['sub_weeks'])));
self::assertEquals('2010-03-01', date('Y-m-d', strtotime($row['add_month'])));
self::assertEquals('2009-11-01', date('Y-m-d', strtotime($row['sub_month'])));
<?php self::assertEquals('2010-01-11', date('Y-m-d', strtotime($row['add_days'])));
self::assertEquals('2009-12-22', date('Y-m-d', strtotime($row['sub_days'])));
self::assertEquals('2010-01-08', date('Y-m-d', strtotime($row['add_weeks'])));
self::assertEquals('2009-12-25', date('Y-m-d', strtotime($row['sub_weeks'])));
self::assertEquals('2010-03-01', date('Y-m-d', strtotime($row['add_month'])));
self::assertEquals('2009-11-01', date('Y-m-d', strtotime($row['sub_month'])));
self::assertEquals('2010-10-01', date('Y-m-d', strtotime($row['add_quarters'])));
<?php self::assertEquals('2009-12-22', date('Y-m-d', strtotime($row['sub_days'])));
self::assertEquals('2010-01-08', date('Y-m-d', strtotime($row['add_weeks'])));
self::assertEquals('2009-12-25', date('Y-m-d', strtotime($row['sub_weeks'])));
self::assertEquals('2010-03-01', date('Y-m-d', strtotime($row['add_month'])));
self::assertEquals('2009-11-01', date('Y-m-d', strtotime($row['sub_month'])));
self::assertEquals('2010-10-01', date('Y-m-d', strtotime($row['add_quarters'])));
self::assertEquals('2009-04-01', date('Y-m-d', strtotime($row['sub_quarters'])));
<?php self::assertEquals('2010-01-08', date('Y-m-d', strtotime($row['add_weeks'])));
self::assertEquals('2009-12-25', date('Y-m-d', strtotime($row['sub_weeks'])));
self::assertEquals('2010-03-01', date('Y-m-d', strtotime($row['add_month'])));
self::assertEquals('2009-11-01', date('Y-m-d', strtotime($row['sub_month'])));
self::assertEquals('2010-10-01', date('Y-m-d', strtotime($row['add_quarters'])));
self::assertEquals('2009-04-01', date('Y-m-d', strtotime($row['sub_quarters'])));
self::assertEquals('2016-01-01', date('Y-m-d', strtotime($row['add_years'])));
<?php self::assertEquals('2009-12-25', date('Y-m-d', strtotime($row['sub_weeks'])));
self::assertEquals('2010-03-01', date('Y-m-d', strtotime($row['add_month'])));
self::assertEquals('2009-11-01', date('Y-m-d', strtotime($row['sub_month'])));
self::assertEquals('2010-10-01', date('Y-m-d', strtotime($row['add_quarters'])));
self::assertEquals('2009-04-01', date('Y-m-d', strtotime($row['sub_quarters'])));
self::assertEquals('2016-01-01', date('Y-m-d', strtotime($row['add_years'])));
self::assertEquals('2004-01-01', date('Y-m-d', strtotime($row['sub_years'])));
<?php self::assertEquals('2010-03-01', date('Y-m-d', strtotime($row['add_month'])));
self::assertEquals('2009-11-01', date('Y-m-d', strtotime($row['sub_month'])));
self::assertEquals('2010-10-01', date('Y-m-d', strtotime($row['add_quarters'])));
self::assertEquals('2009-04-01', date('Y-m-d', strtotime($row['sub_quarters'])));
self::assertEquals('2016-01-01', date('Y-m-d', strtotime($row['add_years'])));
self::assertEquals('2004-01-01', date('Y-m-d', strtotime($row['sub_years'])));
}
<?php self::assertEquals('2009-11-01', date('Y-m-d', strtotime($row['sub_month'])));
self::assertEquals('2010-10-01', date('Y-m-d', strtotime($row['add_quarters'])));
self::assertEquals('2009-04-01', date('Y-m-d', strtotime($row['sub_quarters'])));
self::assertEquals('2016-01-01', date('Y-m-d', strtotime($row['add_years'])));
self::assertEquals('2004-01-01', date('Y-m-d', strtotime($row['sub_years'])));
}