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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T22:16:19+00:00 2026-06-13T22:16:19+00:00

I need to enter dates and time(input as strings) into my database but there’s

  • 0

I need to enter dates and time(input as strings) into my database but there’s no change (remains as 0000-00-00 for the date and 00:00:00 for the time). I know I’m supposed to use DateTime::createFromFormat() but I’m not sure how to go about it. Please be patient and explain to me how I’m supposed to go about it and what is happening in each step and if I want to return the date from the database on later on, how will I go about it? I’m using $date and $starttime , $endtime.

  • 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-13T22:16:21+00:00Added an answer on June 13, 2026 at 10:16 pm

    While inserting, use STR_TO_DATE to convert your String date to Date or DATETIME based on the format as :

       INSERT INTO TABLE1(date, startTime, endtime) 
       VALUES (STR_TO_DATE('$date','%d/%m/%Y'),
              STR_TO_DATE('$starttime','%d/%m/%Y a%h:%i:%s'),
              STR_TO_DATE('$endtime','%d/%m/%Y a%h:%i:%s'));
    

    Similarly use DATE_FORMAT during retrieval to convert into string of desired format as:

      SELECT DATE_FORMAT(date, '%d/%m/%Y') AS formatter_date,
             DATE_FORMAT(starttime,'%d/%m/%Y a%h:%i:%s') AS formatted_startTime
             DATE_FORMAT(endtime,'%d/%m/%Y a%h:%i:%s') AS formatted_endTime
      FROM TABLE1;
    

    Let me know, if you need further explanation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form where a user need to enter date and time (2
I need to enter the start date, start time, end date and end time
I have a console application where I need to input numbers until enter x.
I need to export database from one server and import it into another server.
I've been working on creating a form that submits content into my database but
I have a standard <input> textbox where users enter a date. I'd like to
Is it possible to define input times, like time, date, currency or that should
Have a form where a user can enter start date/time and end date/time for
I have a requirement where i need to enter a text in the text
i have a text field in Contact screen and the user need to enter

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.