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 8418849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:26:28+00:00 2026-06-10T02:26:28+00:00

I have a string of a date: 25/08/2012 And here I’m trying to convert

  • 0

I have a string of a date:

25/08/2012

And here I’m trying to convert it to a DateTime object in order to save it to the MySQL database. My backend schema has a DateOfPrint date column ready to receive this data.

Here’s what I’ve tried:

$eventDate = DateTime::createFromFormat('d/m/y', $fecha->innertext);
echo $eventDate;

The echo statement doesn’t show anything on the screen, and when trying to save it to the database, nothing is saved in that column.

Any suggestions?

  • 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-10T02:26:30+00:00Added an answer on June 10, 2026 at 2:26 am

    Your $eventDate contains a boolean(false) which is printed as empty string.

    You need to use an upper-case Y.

    Y   A full numeric representation of a year, 4 digits    Examples: 1999 or 2003
    y   A two digit representation of a year    Examples: 99 or 03

    And you have to call DateTime::format();
    e.g.

    <?php
    $fecha = new StdClass;
    $fecha->innertext = '25/08/2012';
    
    $eventDate = DateTime::createFromFormat('d/m/Y', $fecha->innertext);
    if ( false===$eventDate ) {
      die('invalid date format');
    }
    echo $eventDate->format('Y-m-d');
    

    prints

    2012-08-25
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jArray and a string from that jArray, message2: [{date:2012,count:1,message : message1},
I have a datetime string like so: > mydatetime [1] 2012-01-07 14:53:52 EST 2012-01-07
I have this string: tag:domain.com,2012-10-12:feed/channel/id/335 Im trying to get the last digits from this
This is sample my database: status date Q 2012-08-02. Q 2012-08-01. Q 2012-09-03. Here
I have been trying to convert between timezones a given date and time. Code
In mysql, i have a field time_entered of type datetime (sample data: 2012-06-20 16:00:47).
I'm trying to select records by date from a Lotus Notes database and have
I have a date string of the form '2009/05/13 19:19:30 -0400'. It seems that
I have a date string and I want to parse it to normal date
i have a long string of date . looks like that : Mon Jun

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.