Reputation: 2647
I'm looking to convert a date from one format to another.
This is my current date format:
2011-08-15 15:35:58
and I need to convert it into:
Mon, 15/08/2011 15:35
I can quite easily create this by cutting the last 3 characters from the time and then using str_replace to change '-' into '/' and so on, but I was wondering if there is there is a way to do this automatically using the date() function or something similar. I am also not sure how to generate the day of the week e.g. 'Mon', 'Tues' etc.
Hope someone can help. Thanks.
Upvotes: 1
Views: 5445
Reputation: 7793
This code work fine:
<?
$time = strtotime("2011-08-15 15:35:58");
echo date("D, d/m/y H:m", $time);
But be carefull, strtotime depends on timezone settings.
Upvotes: 0
Reputation: 14808
This can be done easily using a combination of date()
and strtotime()
:
$newDate = date('D, d/m/Y H:i', strtotime($oldDate));
Upvotes: 4