0% found this document useful (0 votes)
25 views

11.date PHP PDF

The PHP date() function formats a timestamp into a readable date and time string. A timestamp is the number of seconds since January 1, 1970 at 00:00:00 GMT. The first parameter of date() specifies the format of the date using letters like d for day, m for month, and Y for 4-digit year. Other characters can be inserted for additional formatting. The second parameter allows specifying an optional timestamp; if omitted, the current time is used. Other PHP functions like time() and strftime() can also be used to work with dates and timestamps.

Uploaded by

Abdul Rauf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

11.date PHP PDF

The PHP date() function formats a timestamp into a readable date and time string. A timestamp is the number of seconds since January 1, 1970 at 00:00:00 GMT. The first parameter of date() specifies the format of the date using letters like d for day, m for month, and Y for 4-digit year. Other characters can be inserted for additional formatting. The second parameter allows specifying an optional timestamp; if omitted, the current time is used. Other PHP functions like time() and strftime() can also be used to work with dates and timestamps.

Uploaded by

Abdul Rauf
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Date

The PHP Date() Function - Syntax


The PHP date() function formats a timestamp to a more readable date and time.

Date
What is a Timestamp?
A timestamp is the number of seconds since January 1, 1970 at 00:00:00 GMT.
This is also known as the Unix Timestamp.

Date
Format the Date
The first parameter in the date() function specifies how to format the date/time. It uses
letters to represent date and time formats. Here are some of the letters that can be
used:
* d - The day of the month (01-31)
* m - The current month, as a number (01-12)
* Y - The current year in four digits
An overview of all the letters that can be used in the format parameter, can be found in
the W3C PHP Date reference.
Other characters, like"/", ".", or "-" can also be inserted between the letters to add
additional formatting:

Date
Format the Date

The output of the code above could be something like this:

Date
Adding a Timestamp
The second parameter in the date() function specifies a timestamp. This parameter is
optional. If you do not supply a timestamp, the current time will be used.
In our next example we will use the time() function to create a timestamp for tomorrow.
The time() function returns the Unix timestamp for NOW.
....but we can manipulate this.

Date
Other Date Functions
We used time() to generate out timestamp, but there are a number of other useful
time/date functions we can use such as strftime() and mktime()
For the full list check the W3C Date/Time Functions List

You might also like