-1

i have a problem with news script.

the code below will generate today's date, i think it's because that i have date() in the beggining, or maybe the line is just not written right.

the $postdate in the () is a numeric date, such as 13.11.01, again, i get the same date of today on all of the posts in the loop. what's wrong with my line?

i need it to output the date as text one. such as December 13th, 2013

thanks

<?
$postdate = date('F jS, Y', strtotime($postdate));
?>

2 Answers2

0

The problem is likely that strtotime() doesn't recognize the . character as a valid separator. See below:

Strtotime() doesn't work with dd/mm/YYYY format

Community
  • 1
  • 1
flagoworld
  • 3,196
  • 2
  • 20
  • 16
0

First you have a typo on your question.

13.11.01 is November 1st, 2013 , Not November 13th, 2013

So, go the OOPway like this.

<?php
$dt='13.11.01';
$date = DateTime::createFromFormat('y.m.d', $dt);
echo $datex= $date->format('F jS, Y'); //"prints" November 1st, 2013
Shankar Narayana Damodaran
  • 68,075
  • 43
  • 96
  • 126