PHP Date and Time
The date() function.
PHP Date() Function
The PHP date() function is used to format a date and/or a time.
Syntax: date(format, timestamp)
Formatting Characters
- d - Represents the day of the month (01 to 31)
- m - Represents a month (01 to 12)
- Y - Represents a year (in four digits)
- l (lowercase 'L') - Represents the day of the week
- H - 24-hour format of an hour (00 to 23)
- h - 12-hour format of an hour with leading zeros (01 to 12)
- i - Minutes with leading zeros (00 to 59)
- s - Seconds with leading zeros (00 to 59)
- a - Lowercase Ante meridiem and Post meridiem (am or pm)
Timezones
If the time you get back from the code is not correct, it's probably because your server is in another country or set up for a different timezone.
Use date_default_timezone_set("America/New_York"); to set the timezone.