Get the App
SLTechnology News&Howtos  ›  Development  › 

How to set the week for php

Shulou Source: shulou.com Published: 2022-06-02 16:51:51 10月01日 Update

Editor to share with you how to set the week of php, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

The method of setting the week in php: 1. Obtain the numeric week through "date (" w ");" method; 2, obtain the Chinese week through "$weekarray [date (" w ")]; 3, obtain the Chinese week through" date ("w", strtotime ("...")) " Method to get the specified date.

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

What day of the week does PHP get the code:

Date ("l"); / / data can get English days of the week such as Sundaydate ("w"); / / this can get numeric weeks such as 123. note that 0 is Sunday.

Get the Chinese day of the week:

$weekarray=array ("day", "one", "two", "three", "four", "five", "six"); / / define an array echo "week". $weekarray [date ("w")]; / / output: Tuesday

The specified date is:

$weekarray=array ("day", "one", "two", "three", "four", "five", "Saturday"); echo "week". $weekarray [date ("w", strtotime ("2018-12-18"))]; / / output: Tuesday

Because the date function is very powerful, it can do all the work. I have attached a table in the manual for easy reference.

The above is all the contents of the article "how to set the week in php". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Week method article content number date Chinese output powerful not so much code function most manual array more environment computer knowledge system Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Shulou Information Xiaomi MySQL macOS