Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
798 views
in Technique[技术] by (71.8m points)

php - Checking if date falls on weekday or weekend?

How do you check whether a date in the US format of e.g. 2012-01-01 falls on a weekday or weekend in PHP?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
$weekday = date("w", strtotime("2012-01-01"));

This will be 0 for Sunday through 6, Saturday.

http://www.php.net/manual/en/function.strtotime.php

http://php.net/manual/en/function.date.php


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...