The date Function

Started by chinmay.sahoo, 12-19-2015, 02:55:07

Previous topic - Next topic

chinmay.sahooTopic starter

PHP has a very powerful function named date which enables information about the current date and time to be obtained and displayed in a very fl exible way. The date function takes one argument, which can be a string of any length. It reads the system clock to fi nd out the date and time and then returns a string constant with part or all of that information presented in a suitable form, which depends on the string that was given to it as its argument.

We will start by illustrating the effect of calling the function with a one-character string as its argument. If we assume that today is Christmas Day 2018, the function call date("d") will return the string "25", date("F") will return "December" and date("Y") will return "2018".

If the argument is more than one character the string returned is the combination of all the strings returned by the individual characters joined together. So date("dFY") returns the string "25December2018".

A list of the main characters that can be used in the argument of a date function and the outputs they produce is given at the end of this section. Any other characters can also be used. Those that do not have a special meaning return themselves. These include characters such as space, colon, dot and minus (or hyphen), which can be used as separators. Thus executing the instruction


f1dark

Thanks for the information but I am not sure what to do with this.