idate()


 

idate()

The following example of idate() is used for formatting a local time or date as integer.

The following example of idate() is used for formatting a local time or date as integer.

PHP idate()Function

The idate() function formats a local time or date as integer. It returns a default value of time, if no timestamp is given otherwise it returns number formatted according to the given format string using the given integer timestamp or the current local time. 

idate functions similar to function date() but it accepts just one char in the format parameter.

Syntax or Code of idate() Function PHP

int idate ( string $format [, int $timestamp= time() ] )

Parameter & Description of idate() in PHP

format - Format is an essential parameter. It returns the result according to specified parameter. 

  • 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 DST (daylight saving time) is activated, 0 otherwise
  • L - returns 1 for leap year, 0 otherwise
  • m - Month number
  • s - Seconds
  • t - Days in current month
  • U - Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
  • w - Day of the week (Sunday=0)
  • W - ISO-8601 week number of year (week starts on Monday)
  • y - Year (1 or 2 digits)
  • Y - Year (4 digits)
  • z - Day of the year
  • Z - Timezone offset in seconds

timestamp - It is optional and returns the result in the formatted form if date or time is specified or it returns the default timestamp. 

Example of idate() in PHP:

<?php
echo(idate("Y"));
?>

The output of the code above could be:
2006

Ads