idate()
is a built-in PHP function that allows you to extract specific information from a Unix timestamp. It stands for "integer date" and returns an integer value corresponding to the specified format.
Here's the basic syntax:
<?php
idate(format, timestamp)
The format
parameter is a single-letter code that determines what value should be returned, and timestamp
is an optional parameter that specifies the Unix timestamp to extract the information from. If no timestamp is provided, the current date and time will be used.
Here are some examples of the format
parameter and the corresponding integer values returned by idate()
:
idate('Y', $timestamp)
returns the four-digit year, such as 2023.idate('m', $timestamp)
returns the two-digit month, such as 03 for March.idate('d', $timestamp)
returns the two-digit day of the month, such as 05.idate('H', $timestamp)
returns the two-digit hour in 24-hour format, such as 17 for 5 PM.idate('i', $timestamp)
returns the two-digit minute, such as 30.idate('s', $timestamp)
returns the two-digit second, such as 45.
idate()
is useful for extracting specific date and time values from Unix timestamps and manipulating them as needed in your PHP code.
Practice Your Knowledge
Quiz Time: Test Your Skills!
Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.