UberPages :: Tutorials :: PHP Tutorials :: PHP Date Functions

Quick Menu

... More of a reference page than a tutorial: I'll get right to the goods.

If you ever need any kind of date output (always derived from the server), these are the parameters usable on the PHP date function. Drop this onto your PHP page to get started.

<? echo date("D M d, Y H:i:s"); ?>

That will give you something like this:
Sat Feb 04, 2012 11:24:37

As you can already see, that the Date function will respond to already a few parameters passed to it, but there are many more. Here are the rest.

  • A = Uppercase 12hr time syntax eg. PM
  • a = Lowercase 12hr time syntax eg. pm
  • D = Day eg. Sat
  • d = Day eg. 22
  • F = Full Text Month eg. April
  • G = Hours in 24 hour format without leading zeros eg. 17
  • g = Hours in 12 hour format without leading zeros eg. 5
  • H = Hours in 24 hour format with leading zeros eg. 17
  • h = Hours in 12 hour format with leading zeros eg. 05
  • i = Minutes eg. 33
  • M = Month eg. Jan
  • m = Month eg. 01
  • O = GMT time difference in hours eg. +0400
  • S = Day of month suffix eg. st, nd, rd, or th.
  • s = Seconds eg. 28
  • T = Timezone setting eg. GMT, PST, EST, etc
  • t = Total number of days in the month eg. 28, 31, etc.
  • U = Seconds since the UNIX epoch eg. 1041604168
  • W = Week number in year eg. 42 (42nd week in the year)
  • w = numeric representation of the day eg. 1 = monday, 2 = tuesday, etc.
  • Y = Year eg. 2006
  • y = Year eg. 06
  • z = Day of the year eg. 089

That's pretty much it!










Affiliates and Uber Linkage