I am trying to put a readable time and date as part of a file name (in php). I am having all kinds of trouble with this and was hoping someone could help. I have tried several different recommendations that I have read around the internet (plus I read the manual) but I really haven’t gotten anything to work right. Right now I have this:
$Time=strtotime("now");
$date=DateTime::createFromFormat('m/d/Y H:i:s', '7/24/2012 14:40:30');
$date_readable=$date->$Timestamp();
At that point I then add $date_readable to a file name. It compiles and runs but it doesn’t format the date at all. It still gives it as a timestamp.
Any suggestions on how to make this work?
you can do it with simple date function for example
this will print something like
DateTimeclass is more powerful then using simpledatefunction, asDateTimeclass offers powerful API’s plus it is object oriented. however for simple date conversions i would stick to php’s date function. as that could do my purpose.for more formatting option have a look at this link http://www.php.net/manual/en/function.date.php#refsect1-function.date-parameters