How in php to perform an action every first day of the month?

How can I do that without the crown?
July 2nd 19 at 18:16
4 answers
July 2nd 19 at 18:18
Solution
start
foo();

sleep((new DateTime())->diff((new DateTime())->modify('+1 month'))->format('%a')*24*60*60);
goto start;

Run once on the first.
And how to make more flexible, to be able to change this date in a variable? - Kendrick_Schu commented on July 2nd 19 at 18:21
: Seriously, that was a bad joke with goto sleep.
More flexibility can be done php.net/manual/ru/datetime.setdate.php
The main problem is that the script will also when you first stop the server. - evie.Feil6 commented on July 2nd 19 at 18:24
: why setdate? I was thinking we might like something simpler, like if(today's the first?) {condition} - Kendrick_Schu commented on July 2nd 19 at 18:27
: More flexibility for me is the ability to set any number. But if to solve the task, the figachit if(date('d') === '01'){}

I do not recommend all that spike shit to use it :) - evie.Feil6 commented on July 2nd 19 at 18:30
yeah, studying datetime. Thank you! - Kendrick_Schu commented on July 2nd 19 at 18:33
July 2nd 19 at 18:20
need hits on the village then. Without hits or the crown in any way.
Yes, the hits will be - Kendrick_Schu commented on July 2nd 19 at 18:23
July 2nd 19 at 18:22
Via SSH run file for permanent implementation, and the code sveryay date and perform an action, more details on habré can read.
July 2nd 19 at 18:24
Some nonsense answers or did not understand the question?!
Get the date that has come a certain date, hours, and perform what you need

Find more questions by tags PHP