PHP has many easy-to-use functions for displaying and processing dates. To display date or time in a specific format, use the date() function. It takes two parameters: the format in which the date should be displayed and the timestamp representing the date you want to display. This timestamp must be the total number of seconds since 1970 as mentioned earlier (if you want to use the current time, use the time() function, which returns the "now" timestamp). date() has many formatting options, just like the strftime() function in C or the POSIX::strftime() function in Perl. $birthday_stamp = mktime(19,45,0,3,10,1975); $birthday_formatted = date('F d, Y - g:ia',$birthday_stamp) ; echo "David was born on $birthday_formatted." ?> will display David was born on March 10, 1975--7:45 p.m. Of course, if you need This complex formatting function is not very useful for a known specific date. Because you already know in advance what your format will be. These functions are useful when dealing with form output that requires the user to select a date:
The above will output a radio button with ten options - today and The next nine days. Before the program loop starts, we store the current time in the variable $d. Each
http://www.bkjia.com/PHPjc/317075.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/317075.htmlTechArticlePHP has many easy-to-use functions for displaying and processing dates. To display a date or time in a specific format, use the date() function. It has two parameters: How to display the date in a format...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn