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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:02:56+00:00 2026-06-06T18:02:56+00:00

Currently, my code to insert into the database is as follows: mysql_query(INSERT INTO lookup_table

  • 0

Currently, my code to insert into the database is as follows:

mysql_query("INSERT INTO lookup_table (
    the_date
        )
VALUES(
        NOW()
)
";)

In one line, that’s:

mysql_query("INSERT INTO lookup_table (the_date) VALUES(NOW())";)

The problem is, for some reason, NOW() as I have it here is recording into the database a 12-hour clock. (1:03 PM records as 01:03:00, instead of 13:03:00.)

What can I do to specify to NOW() that it be formatted as 24-hour?

I have read a lot about formatting things. Unfortunately, as has happened many times in the past, there are small, almost imperceptible formatting issues that can make things not work out quite right.

I am trying to make sure I do not do a long time of trial-and-error to make sure I get the formatting correct.

I THINK that the line that says “NOW()” should be replaced with “DATE_FORMAT(NOW(), %Y-%m-%d %T)“, but I am looking for independent confirmation that does not have me leading the witness, and someone saying “yeah that looks good enough.”

Right now, entries in the database look like this:

2012-06-27 01:03:36

Which would be perfect, were it not that the time should read 13 instead of 01, like so:

2012-06-27 13:03:36

I know that “NOW()” is working, it just needs to be 24 hour format, which it is SUPPOSED to be by default. For some reason this is not happening, and I’d just like to know what specific alphanumeric sequence to put in the stead of “NOW()” to record as a 24-hour format.

  • 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-06T18:02:58+00:00Added an answer on June 6, 2026 at 6:02 pm

    Given the documentation for NOW(), I suspect that either your system is configured very strangely somehow, or you’re in a time zone which is currently 12 hours “out” from UTC. (Or your server is configured to just use UTC, so it’s giving the UTC time but you were expecting local time.) There’s no indication from the documentation that the format returned by NOW() is affected by any cultural settings, for example.

    I would suggest that in general, storing the result of UTC_TIMESTAMP() would be a better approach anyway – but of course you’ll still want to make sure you end up with a sensible format.

    What do you see in the morning, and do you see the same effect if you just use

    SELECT NOW(), UTC_TIMESTAMP()
    

    from an interactive query window? Likewise, do you have any other servers you could try the same query against? Which version of MySQL are you running?

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

Sidebar

Related Questions

I am using QSqlQuery to insert data into a MySQL database. Currently all I
I have an entity Report whose values I want to insert into a database
I'm trying to insert registration data into a database but my php code isn't
I am currently trying to simply insert a new row into my SQLite3 database
I currently have code that does the following: private final static ExecutorService pool =
I currently have code in objective C that can pull out an integer's most
I have written the following code for inserting video bytes into the database DBAdapter.java
I'm trying to insert information from a form into a database table and then
Trying to copy a database into a new database, using a PHP script that
I am currently developing an Android app that is using a remote MySQL database

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.