How to get the current Date and Time in PHP ?
The purpose of the article is to get the current Date and Time in PHP. It is performed by using a simple in-built PHP function date(). The Date is an inbuilt function used to format the timestamp. The computer stores date and time in UNIX timestamp. This time is measured as a number of seconds since Jan 1, 1970. As this is difficult for humans to read, PHP converts timestamps to format in such a way that it is readable and more understandable to humans.
Parameters : The date() have different parameters. Each parameter represents some meaningful unit.
- d: It represents the day of the month which has two digits with leading zeros (01 or 31)
- m: It represents month in numbers with leading zeros (01 or 1)
- y: It represents a year in two digits (08 or 14).
- h: It represents the hour of the day in two digits with leading zeros (01 or 1)
- I: It represents the minute in the current time zone.
- s: It represents the number of seconds in the current timezone.
Current date and time is :03-01-21 04:49:52
Example 2: The following demonstrates other date() functions format which can be used by the developer as per the need.
My Personal Notes arrow_drop_up
Please Login to comment...