Php specifies the date of the week

Source: Internet
Author: User
Tags echo date
Php specifies the date to obtain the format of the day of the week, such as 20151225. How can I find the day of the week... Ask for advice.


Reply to discussion (solution)

$ Time = time ();
Echo date ('D', $ time); // The Day of the week, represented in text, with three letters Mon to Sun
Echo date ('L', $ time); // The Day of the week. The Complete Text format is Sunday to Saturday.
Echo date ('N', $ time); // The Day of the week represented by a number in ISO-8601 format (PHP 5.1.0 plus) 1 (Monday) to 7 (Sunday)
Echo date ('W', $ time); // The Day of the week. The number indicates 0 (Sunday) to 6 (Saturday)


Baidu one search engine ....

$ Time = time ();
Echo date ('D', $ time); // The Day of the week, represented in text, with three letters Mon to Sun
Echo date ('L', $ time); // The Day of the week. The Complete Text format is Sunday to Saturday.
Echo date ('N', $ time); // The Day of the week represented by a number in ISO-8601 format (PHP 5.1.0 plus) 1 (Monday) to 7 (Sunday)
Echo date ('W', $ time); // The Day of the week. The number indicates 0 (Sunday) to 6 (Saturday)


Baidu one search engine ....


Brother, you get the current timestamp .... I am asking about the specified date... Format like 20151225 .. 20151225 is not the timestamp .. Eldest brother

Do you know that the date will not be converted into a timestamp?

Do you know that the date will not be converted into a timestamp?


$time = strtotime("2015-12-12");echo date('N', $time);

I thought there were some original functions. The results still have to be done...
Close the post ..
Here, we will first convert a string like 20151225 into an array using the str_split function. Then manually splice them into the required format. The code is as follows. Hope to help people in the future ..

$str = str_split("20151225");$time = $str[0].$str[1].$str[2].$str[3]."-".$str[4].$str[5]."-".$str[6].$str[7];echo date("l",strtotime("$time"));

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.