Home>Article>Backend Development> How to get the day of the week based on time in php
php method to get the day of the week based on time: 1. Get the Chinese day of the week through "$weekarray[date("w")]; 2. Through "$weekarray[date("w",strtotime ("xxx"))];" Get the specified date.
The operating environment of this article: Windows 7 system, PHP version 7.1, Dell G3 computer
How does php get the day of the week based on the time?
php gets the day of the week when the time is
PHP gets the day of the week code:
date("l"); //data就可以获取英文的星期比如Sunday date("w"); //这个可以获取数字星期比如123,注意0是星期日
Gets the Chinese day of the week:
$weekarray=array("日","一","二","三","四","五","六"); //先定义一个数组 echo "星期".$weekarray[date("w")];
Gets the specified date is :
$weekarray=array("日","一","二","三","四","五","六"); echo "星期".$weekarray[date("w",strtotime("2011-11-11"))];
Related introduction:
PHP (PHP: Hypertext Preprocessor) is a "hypertext preprocessor". It is a scripting language executed on the server side. It is especially suitable for web development and can be embedded. in HTML. PHP syntax learned the C language, absorbed the characteristics of multiple languages of Java and Perl to develop its own unique syntax, and continued to improve itself based on their strengths, such as Java's object-oriented programming. The main goal of the language was originally created to make Developers quickly write high-quality web sites. PHP supports both object-oriented and process-oriented development, and is very flexible in use.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to get the day of the week based on time in php. For more information, please follow other related articles on the PHP Chinese website!