Docsity

date and time in php study slides, Study notes of Programming Languages

Partial preview of the text

Download date and time in php study slides and more Study notes Programming Languages in PDF only on Docsity!

PHP Date and Time

2022 - 2023

PHP DATE

2 Eng. Hazem A. Alrakhawi

Get a Date

  • Here are some characters that are commonly used for dates format:
  • 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.
  • Other characters, like"/", ".", or "-" can also be inserted between the characters to add additional formatting.

Get a Date

  • The example below formats today's date in three different ways:

PHP TIME

7 Eng. Hazem A. Alrakhawi

Get a Time

  • Here are some characters that are commonly used for times:
  • 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)

Get a Time

  • The example below outputs the current time in the specified format:

TIME ZONE

11 Eng. Hazem A. Alrakhawi

Get Your Time Zone

  • The example below sets the timezone to "America/New_York", then outputs the current time in the specified format:

Get Your Time Zone

  • The example below sets the timezone to “Asia/Gaza", then outputs the current time in the specified format:

Get Your Time Zone

  • For more timezone format, you can visit:

https://www.php.net/manual/en/tim

ezones.php

Get Your Time Zone

The End. 2022 - 2023