Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7806471
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T02:32:49+00:00 2026-06-02T02:32:49+00:00

I have a table with string values in the format of Friday 20th April

  • 0

I have a table with string values in the format of Friday 20th April 2012 in a field called Film_Release

I am looping through and I want to convert them in datetime and roll them out into another table. My second table has a column called Films_Date, with a format of DATE. I am receiving this error

Object of class DateTime could not be converted to string

$dateFromDB = $info['Film_Release'];
$newDate = DateTime::createFromFormat("l dS F Y",$dateFromDB); //( http:php.net/manual/en/datetime.createfromformat.php)

Then I insert $newdate into the table through an insert command.

Why am I be getting such an error?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T02:32:51+00:00Added an answer on June 2, 2026 at 2:32 am

    Because $newDate is an object of type DateTime, not a string. The documentation is explicit:

    Returns new DateTime object formatted according to the specified
    format.

    If you want to convert from a string to DateTime back to string to change the format, call DateTime::format at the end to get a formatted string out of your DateTime.

    $newDate = DateTime::createFromFormat("l dS F Y", $dateFromDB);
    $newDate = $newDate->format('d/m/Y'); // for example
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table with string values that need to matched individually to a
I have a date in the string format in a table and I need
I have one column in my table which will store data in string format
I have a field in an Azure table that holds date times in string
I have a table logout with columns logout_id logout_datetime values format like this(2011-09-08 11:09:09)
Lets say I have table with ID int, VALUE string: ID | VALUE 1
I have a table with 5 string columns, all can be NULLs. After I
I have a table as Name(String) fromRange(int) toRange(int) abc 15160 15180 bhy 12510 12515
Lets say I have table with following columns 1. Client - string. 2. Profit
In a SQL Server 2000 DB, I have a table which holds string representations

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.