Jump to content

Date format


Xtremer360

Recommended Posts

I'm trying to turn 2012-09-12 14:00:00 into September 12, 2012 2:00 pm using the php date function but I'm getting a  A non well formed numeric value encountered error and not sure if I just didn't apply the function correctly or am missing something. Any ideas?

 

date('F d, Y h:i:s a', $row->news_article_posting_date)

Link to comment
https://forums.phpfreaks.com/topic/268308-date-format/
Share on other sites

date() accepts an integer in the form of a timestamp as the second parameter. You are probably passing it a string: "2012-09-12 14:00:00." Try using strtotime():

 

date('F d, Y h:i:s a', strtotime($row->news_article_posting_date))

 

http://us2.php.net/manual/en/function.date.php

http://us2.php.net/manual/en/function.strtotime.php

Link to comment
https://forums.phpfreaks.com/topic/268308-date-format/#findComment-1377410
Share on other sites

Well I'm working it into my query but I'm getitng a

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING in /home/xtremer/public_html/kowmanager/app/models/news_model.php on line 31

 

 

$this->db->select("DATE_FORMAT(".$this->master_model->news_articles_table.".news_article_posting_date, '%M %D, %Y') AS news_article_posting_date", FALSE);
$this->db->select("CONCAT_WS(' ', ".$this->master_model->users_table.".first_name, ".$this->master_model->users_table.".last_name) AS author", FALSE);

Link to comment
https://forums.phpfreaks.com/topic/268308-date-format/#findComment-1377427
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.