peter-cooper
asked on
Convert date to dd/mm/yyyy
Hello
I am struggling to convert a date that I use as part of a filename of a zip file. At the moment it prints
I have posted the code I am using and would be grateful if someone could help with this. Thanks
I am struggling to convert a date that I use as part of a filename of a zip file. At the moment it prints
bootstrap_21-Jun-2017-16-0but I need to have it print4-09-PM.zi p
bootstrap_21/06/2017 16-04-09-PM.zip
I have posted the code I am using and would be grateful if someone could help with this. Thanks
$dateformat='d-M-Y-H-i-s-A';
case 'backupfile':
echo $_POST['db'].'_'.date($dateformat, time());
break;
You can't use '/' as part of a filename in Windows, Linux, or Mac OSX operating systems.
Have you tried this?
$dateformat='d/m/Y H-i-s-A';
Oh, yes, Dave is right, not as a filename!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> but I need to have it print bootstrap_21/06/2017 16-04-09-PM.zip
If you mean that you want that printed/echoes on the browser try using:
If you meant that you want that as the actual filename then it won't work because there are some characters that are not allowed in filenames and the "/" is one of them.
If you mean that you want that printed/echoes on the browser try using:
$dateformat='d/M/Y H-i-s-A';
If you meant that you want that as the actual filename then it won't work because there are some characters that are not allowed in filenames and the "/" is one of them.
ASKER
Thanks very much dave. I learnt something new today.
YOu're welcome, glad to help.
You may want to learn about the ISO-8601 standard for date formats. If you use that, you'll never go wrong!