PHP idate() 函数

实例

格式化本地时间/日期为整数。测试所有不同的格式:


Run Example

Definition and Usage

The idate() function formats the local time/date as an integer.

Note:The idate() function only accepts one character as format Parameter!

Syntax

idate(format,timestamp);
Parameters Description
format

Required. Specifies how to return the result:

  • B - Swatch Beat/Internet Time
  • d - Day of the month
  • h - Hour (12-hour format)
  • H - Hour (24-hour format)
  • i - Minutes
  • I - Returns 1 if daylight saving time is enabled, otherwise returns 0
  • L - Returns 1 if it is a leap year, otherwise returns 0
  • m - Month number
  • s - Seconds
  • t - Total number of days in the month
  • U - The number of seconds since the Unix epoch (January 1 1970 00:00:00 GMT), the same as time()
  • w - Day of the week (Sunday is 0)
  • W - ISO-8601 formatted year, the nth week of the year, starting from Monday
  • y - Year (1 or 2-digit number)
  • Y - Year (4-digit number)
  • z - Day of the year
  • Z - Timezone offset in seconds
timestamp Optional. Specifies the Unix timestamp representing the date/time to be formatted. The default is the current local time (time()).

Technical Details

Return value: Returns according to the specified format Use the given timestamp Formatted integer.
PHP Version: 5+
Update Log: PHP 5.1.0: Added E_STRICT and E_NOTICE timezone errors.