
Quick Reference
The PHP gmdate() function formats a GMT/UTC date and time, and returns the formatted date string.
<?php
// prints the day
echo gmdate('l') . '<br>';
// prints the day, date, month, year, time, AM or PM
echo gmdate('l jS \of F Y h:i:s A') . '<br>';
// prints January 11, 2013 was on a Friday
echo 'Jan 11, 2013 was on a ' . gmdate('l', mktime(0, 0, 0, 11, 1, 2013)) . '<br>';
// uses a constant in the format parameter
echo gmdate(DATE_RFC822) . '<br>';
// prints something like: 2013-11-01T00:00:00+00:00
echo gmdate(DATE_ATOM, mktime(0, 0, 0, 11, 1, 2013));
?>
Output
Monday
Monday 25th of September 2023 07:21:28 PM
Jan 11, 2013 was on a Friday
Mon, 25 Sep 23 19:21:28 +0000
2013-11-01T00:00:00+00:00
Syntax
gmdate(format, timestamp)
Parameters
PHP Notes:
- When using PHP, single or double quotation marks are acceptable and work identically to one another; choose whichever you prefer, and stay consistent
- Arrays count starting from zero NOT one; so item 1 is position [0], item 2 is position [1], and item 3 is position [2] … and so on
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.