
The second parameter value is timezone and it is accepted so that the timezone of the relevant time can be specified. The first parameter value is the time that is accepted for the specification of a date/time string.Īs an optional parameter value, it has NULL as its value type which indicates the current time. Moreover, the syntax of the date_create() function is date_create (time, timezone) which shows that two parameter values are accepted by this function. The “H” character corresponds to the 24-hour format of the specified hour, whereas “i” and “s” highlight the minutes and seconds that are led by zeroes simultaneously: ĭate_create is another important function that is greatly used when returning a new DateTime object. “H,” “i,” and “s” are the characters that have been used in the format parameter value in this example. It shows how the date_create and date_format functions can work together. The following is a simple example of the usage of the date_format function to return a new DateTime object and format date in PHP. – Example of the Usage of the date_format Function The last predefined constant that we will be discussing is DATE_RFC850 – RFC 850 and “Thursday, 15-Jul-16 17:34:01 UTC” is one of its many examples. In addition, DATE_RFC822 – RFC 822 can be written as “Thu, 15 Jul 16 17:34:01 +0000” as a predefined constant. Moving on, DATE_ISO8601 – ISO-8601 is also a predefined constant with “T17:34:01+0000” as an example. Moreover, HTTP Cookies is another predefined constant, and “Thursday, 15-July-16 17:34:01 UTC” is an example of it. One of the primary ones is DATE_ATOM – Atom and an example of it can be “T17:34:01+00:00. There are certain predefined constants as well that can be used along with the date_format function. Predefined Constants of Format Parameter Value It comprises 1 and 0, where 1 refers to a leap year and 0 shows that it is not a leap year. While the character “L” will determine if a specified year is a leap year or not. Then, you can get the total number of days in a specified month by using the character “t”. The character “n” is used to represent a month numerically which is not led by zero and ranges between 1 and 12.
Php date format full#
With the usage of “l” as a character, you can represent a day in a full textual form. Also, a month can be represented in a short textual form with the help of the “M” character which consists of three letters.

You can also numerically represent a month by using the character “m” which has a range from 01 to 12. Characters “F,” “m,” “M,” and “I”Īpart from these characters, “F” is used for a complete textual representation of a month and involves all the months from January to December. Another important character is “j” which corresponds to the day of a month that is not led by zero and ranges from 1 to 31. In contrast, “D” is also a character that acts as the textual representation of a day and comprises three letters. One of the widely used characters is “d” which refers to the day of a month and can range from 01 to 31. There is a huge number of characters that can be used in the format parameter value. – Characters and Predefined Constants of the Format Parameter Value Characters “d,” “D,” and “j” The format is accepted as the second parameter value which is involved in the specification of the format that has to be set for the date. What’s more, the object parameter value is accepted for the specification of a DateTime object that can be returned to the user by the date_create() function. The date_format function accepts two mandatory parameter values which can be called object and format. Parameter Values of the date_format Function The concept of this function is similar to another function which is denoted as date() and used to format a local time or date. Furthermore, the syntax of the date_format function is date_format (object, format). Keep in mind that locales are not used in this function and the output is completely in English.

PHP date_format: Understanding the Functionĭate_format is a useful function that can be used to return a date that is formatted based on the PHP datetime format specified by the user.

– Characters and Predefined Constants of the Format Parameter Value.Parameter Values of the date_format Function.PHP date_format: Understanding the Function.
