My Books

Text Processing with JavaScript

Solve complex text validation, extraction, and modification problems efficiently in JavaScript.

Modern Async JavaScript

Delve into async features of JavaScript from ES2020 through ESNext. Start building custom asynchronous iterators and generators, and more for fast, lean code.

JavaScript Brain Teasers

Ready to test your JavaScript skills? Challenge yourself with these brain-teasing puzzles, supercharge your learning journey, and emerge as a JavaScript pro.

PHP – Number of Days in a Month

When we write a web application using php that deals with date we usually need to find out the number of days in a month. Using PHP you can easily calculate the number of days in a month using PHP  strtotime() function, all you have to do is to pass the desire month as argument to strtotime function and then use the date function, with the “t” placeholder.

Here is how it works:

$timestamp = strtotime("April");
$days = date("t", $timestamp); 
echo $days; // 30

Have your say