How to get the day of the week based on time in php

藏色散人
Release: 2023-03-12 15:48:01
Original
5593 people have browsed it

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.

How to get the day of the week based on time in php

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是星期日
Copy after login

Gets the Chinese day of the week:

$weekarray=array("日","一","二","三","四","五","六"); //先定义一个数组 echo "星期".$weekarray[date("w")];
Copy after login

Gets the specified date is :

$weekarray=array("日","一","二","三","四","五","六"); echo "星期".$weekarray[date("w",strtotime("2011-11-11"))];
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!