PHP Specifies the day of the week to find out

Source: Internet
Author: User
Tags echo date
Like 20151225 in this format. What method to find out is the day of the week ... The new person asks for advice.


Reply to discussion (solution)

$time = time ();
echo Date (' D ', $time); Day of the week, the text indicates that 3 letters Mon to Sun
echo Date (' L ', $time);//day of the week, full text format Sunday to Saturday
echo Date (' N ', $time),//iso-8601 format digit Day of the week (PHP 5.1.0 new Plus) 1 (for Monday) to 7 (for Sunday)
echo Date (' W ', $time);//day of the week, number represents 0 (representing Sunday) to 6 (for Saturday)


Baidu a search a lot of ....

$time = time ();
echo Date (' D ', $time); Day of the week, the text indicates that 3 letters Mon to Sun
echo Date (' L ', $time);//day of the week, full text format Sunday to Saturday
echo Date (' N ', $time),//iso-8601 format digit Day of the week (PHP 5.1.0 new Plus) 1 (for Monday) to 7 (for Sunday)
echo Date (' W ', $time);//day of the week, number represents 0 (representing Sunday) to 6 (for Saturday)


Baidu a search a lot of ....


Big Brother, you this time is getting the current timestamp .... I asked for a date ... Format like 20151225: And 20151225 is not a timestamp. Brother

You know the date doesn't turn the date into a timestamp, baby?

You know the date doesn't turn the date into a timestamp, baby?


$time = Strtotime ("2015-12-12"); Echo date (' N ', $time);

I thought there was something about the original function. The result is to kill Kung fu ...
Then knot paste.
My way is to make 20151225 of such a string into an array with the Str_split function first. Then manually stitch into the required format. The approximate code is as follows. Hope to be helpful to 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 "));
  • Related Article

    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.