Function to convert 'd-m-Y' date to crontab format (* * * * *)

Hi
Has anyone got a function to convert dates in 'Y-m-d' or 'd-m-Y' format to the crontab format * * * * *  ?
Thanks
tr5
tr5Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Hube02Connect With a Mentor Commented:
You could also try the following:
$date = '2009-10-21';
$date = date('i H d m w', strtotime($date));
echo $date;

Open in new window

0
 
hernst42Commented:
It's just

function crontabtime($datestr) {
list($y,$m,$d) = explode('-', $datestr);
if ($y > 31) list($d, $,m, $y);
return "0 0 $d $m *";
}

Not possible to use year
0
 
Jonah11Commented:
hi hernst,

can you explain what is happening in this code:

if ($y > 31) list($d, $,m, $y);
return "0 0 $d $m *";

what is the significance of 31?  also, i've never seen list() used when it was not followed by an "=" sign.  can you explain your usage above?

thanks,
jonah
0
 
tr5Author Commented:
Thanks
0
All Courses

From novice to tech pro — start learning today.