WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This is more of a PHP question than a WordPress one.

I have a custom post type event that by default outputs the date as "September 11, 2011 9:00 am" format.

I'm trying to format the post in http://schema.org/Event format, I have converted every other part of the post to that format (place,address, etc) except the dates.

Any help on how to convert that format to ISO8601 (http://en.wikipedia.org/wiki/ISO_8601) date format ?

Thanks in advance.

share|improve this question
up vote 4 down vote accepted

Use the_time or get_the_time, which accept the same format parameters as php's date.

// assign to a variable
$iso8601_date = get_the_time('c');

// or output directly

EDIT- converting formats with php:

$date = "September 11, 2011 9:00 am";
$time = strtotime( $date );
echo date( 'c', $time );
share|improve this answer
Thanks for the reply. But I forgot to mention that I'm using a plugin called event-calendar-pro and it outputs this time through a function called <?php echo sp_get_start_date(); ?> and I need to convert that to the ISO8601 format. Sorry for the confusion. I did not mean the date of the wordpress post. – Sri Sep 12 '11 at 16:51
@Sri - see edit above – Milo Sep 12 '11 at 17:06
Thanks a lot. You guys are great. – Sri Sep 12 '11 at 19:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.