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
847 views
in Technique[技术] by (71.8m points)

date - How do I find what day the last saturday of the current month is in PHP?

This works for most months, but for example, April 2011 has 5 saturdays, so this returns 23 instead of 30.

$last_saturday = date("j", strtotime('Fourth Saturday'.date('F o')));
See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

Interestingly enough, strtotime("last saturday of this month") does exactly that.

See Supported Date and Time Formats for more, particularly the section on Relative Formats.


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

...