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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:55:15+00:00 2026-06-09T16:55:15+00:00

I get an error when i try to string replace the date and save

  • 0

I get an error when i try to string replace the date and save it in the mySQL db. The reason is the format of the DATE field. i have added my PHP code, and mySQL error message below.

$nowDate = str_replace('/', '-', $_POST['datenow']); 

echo $nowDate;

Output > 08-15-2012 , I am inserting this record to the database, but the MySQL database requires the format yyyy-mm-dd (2012-08-15) or else i get an error

Unable1 to run query:Incorrect date value: '08-15-2012' for column 'now_date' at row 1
  • 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-09T16:55:16+00:00Added an answer on June 9, 2026 at 4:55 pm

    As the error specifies, the format of the date needs to be yyyy-mm-dd.

    You can format it prior to inserting it with date() and strtotime():

    $nowDate = date('Y-m-d', strtotime($_POST['datenow']));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error when I try to use time_ago_in_words : Comparison of String
I get an error when I try to create a table in mysql. Any
Whenever i try using php with lighttpd on my iphone i get error 500
I get Compiler Error C2248 when i try to compile the following code: #include
When I try to run this script i get error in IE: Unterminated string
I get this error when i try to upload an image: OSError at /upload/
Why do I get an error when I try to set the ImageIcon of
Why do i get an error when I try using _ instead of using
Working with H2 I get this error when I try to write a row
When we try to create a view within a funcion we get ERROR: there

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.