Converting a date with PHP
-
In a plugin my colleague made, we’ve successfully made a date display for an event by writing:
<?php if ($display_date = get_post_meta($post->ID, 'start-date', true)): ?> <?php echo $display_date;?> <!-- the page displays 07-15-13 --> <?php endif;?>but, I want to convert those impersonal digits to Monday, July 15, 2013. Now, I know all about ‘l, F jS, Y’ PHP, but when I try to put ‘l, F jS, Y’ and that sort of thing, I get Monday, January 1, 1970. Here is what I inserted trying to find a solution:
<?php if ($display_date = date('l, F jS, Y', strtotime(get_post_meta($post->ID, 'start-date', true)))): ?> <!-- This does not work, it does not pick up the actual 'start_date' -->How do I grab the start date and convert the way the date displays at the same time?
The topic ‘Converting a date with PHP’ is closed to new replies.