PHP Classes

Date & Time Formating

Recommend this page to a friend!

      Top level forums  >  PHP Specialists  >  General  >  Date & Time Formating  
Subject:Date & Time Formating
Summary:Formating
Messages:1
Author:Stephen
Date:2013-09-14 15:17:47
Update:2013-09-14 16:52:07
 

  1. Date & Time Formating   Reply   Report abuse  
Picture of Stephen Stephen - 2013-09-14 16:52:07
Hello
I am trying to format the date and time from an email header inorder to store in a MYSQL database as Datetime variable

The following seems logical, but doesn't work

// Read Header
$datestr = $overview->date;
// Format data string
$dateTime = DateTime::createFromFormat('D, d M Y H:i:s O', $datestr);

$errors = DateTime::getLastErrors();
if (!empty($errors['warnings'])) {
echo "Invalid Date\n"; }

// variable to store
$date = $dateTime->format('Y-m-d H:m:s');

Error
Fatal error: Call to a member function format() on a non-object in

Any advise would be appreciated
Thank you