CLiown
CLiown

Reputation: 13843

PHP string to Date and Time

I have the following string: 2010-04-08T12:46:43+00:00

I want to convert that to:

8th April 2010 @ 12:46

Is that easy enough?

Upvotes: 0

Views: 2538

Answers (4)

Devner
Devner

Reputation: 7245

Here you go.

EDIT : Exactly as you needed

Code:

$time_value = strtotime("2010-04-08T12:46:43+00:00");
$date_in_your_format = date( 'jS F Y @ g:i', $time_value);  
echo $date_in_your_format;

Upvotes: 2

zerkms
zerkms

Reputation: 254926

yep. use strtotime() + date()

Upvotes: 1

Hans
Hans

Reputation: 331

Take a look at strtotime to create a UNIX timestamp from your time string, and then use date($format, $UNIXtimestamp); to create a normal date again:

$Timestamp = strtotime("2010-04-08T12:46:43+00:00");
echo date("your time format", $Timestamp);

You can look up the specific characters for the time format from PHP.net

Upvotes: 2

Amber
Amber

Reputation: 526613

Try taking a look at strtotime() and date().

Upvotes: 0

Related Questions