A Calendar with PHP (starting with Monday)




In this video, I’m going to share how to develop a calendar starting with Monday.
(If you want to create Sunday start calendar, please check this post.)

I think coding a calendar is the best way to get used to Date function.

In this video, you’ll use several date formats like N, j, F, t…
But you don’t need to remember all of them. (I still forget what N stands for!)
Just know how to use them 🙂

Hope you enjoy coding!


MAMP / PHP version7.1.19 (Required PHP 5.4 or later)
Text EditorCoda2
BrowserGoogle Chrome



A Calendar with PHP (Starting with Monday)


Tips & Memo

Date Format

date($format, $timestamp);
$timestamp is optional and defaults to the current time.

FormatReturned Value
MonthFJanuary ~ December
m01 ~ 12
Dayj1 ~ 31
N1:Mon 2:Tue … 7:Sun
t28 ~ 31



strtotime($time_string, $timestamp);
$timestamp is optional and defaults to the current time.


date(‘Y-m-d’, strtotime(‘-1 month’));
date(‘Y-m-d’, strtotime(‘+3 week’));
date(‘Y-m-d’, strtotime(‘+2 day’));
date(‘Y-m-d’, strtotime(‘last Monday’));


Be careful of the base timestamp.

Example: Get the date one month before July.

echo date(‘Y-m-d’, strtotime(‘2018-07-01 -1 month’));
→ 2018-06-01


echo date(‘Y-m-d’, strtotime(‘2018-07-31 -1 month’));
→ 2018-07-01


Sample Code


Working as a freelance programmer in Japan. I try to make coding as simple as possible. Hope you enjoy coding🙂