Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to check if today is the first of the month [duplicate]

Tags:

date

php

I have 2 functions for checking if today is the first day of the month. Does one of these have an advantage over the other, ie accuracy?

if(date('j', $timestamp) === '1') { }

if(date('Y-m-d') == date('Y-m-01')) { }
like image 954
Naterade Avatar asked Jul 31 '13 22:07

Naterade


1 Answers

The first one does less checking I would use that.

You also don't need the timestamp argument if you want to check now / today

like image 120
exussum Avatar answered Oct 06 '22 00:10

exussum