Hi All
I need a script that will count the days, hours and minutes to the end of the month and then rest itself at the beginning of the next month.
Does anyone have one I can use or can point me in the direction of one?
Thanks for any help.
mrmbarnes
You could you some of the native functionality, something similar to the following should do the trick.
<?php
$now = new DateTime;
$end = new DateTime('next month');
echo $now->diff($end)->format('%R%a days');
It’s untested, so be sure to check out the manual; I also think DateTime::diff is PHP 5.3+ only too.
It is, which is a real PITA. I whipped up some code to emulate this in pre-5.3 PHP, reams of code to do what 5.3 does in three lines
Hey
My server is running 5.2.12 so the code didn’t work but thanks.
Any chance of seeing the other code that works on pre 5.3?
Many Thanks