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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:51:12+00:00 2026-05-23T07:51:12+00:00

When each item is entered into the db i use the following method to

  • 0

When each item is entered into the db i use the following method to insert date:

 date_default_timezone_set('America/New_York');
 ob_start();
 $createdon = date('l, F j, Y, h:i A');
 ob_get_clean();

This outputs something like:

  Tuesday, May 3, 2011, 04:50 PM

This is the query:

  select test_id, why_test, date_time
  from the_test
  where p_id = '$id'
  UNION
  select pencil_id, pencil_name, date_time
  from pencils
  where p_id = '$id'
  ORDER BY 3 DESC  

Now when i user the order by function it doesn’t do it properly. The dates are still being mixed up. I used order by date_time DESC.

I am using php/phpmyadmin.

Any ideas?

  • 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-05-23T07:51:12+00:00Added an answer on May 23, 2026 at 7:51 am

    Storing a date as a string is wrong. You should store a date as a date.

    MySQL has a selection of appropriate types relating to dates and times; I’d recommend either TIMESTAMP or DATETIME (probably the latter; look it up in the manual to see what’s best for you).

    To avoid losing your existing data when you fix your table structure:

    • Add a field with the right type;
    • Update each row in your table to copy the data to the new field, possibly with the UNIX_TIMESTAMP function — this is a one-time copy, which might take some time;
    • Delete the old field and starting using the new one instead.

    ORDER BY will work naturally on this field, as you will now be using MySQL as it is designed to be used.

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

Sidebar

Related Questions

Each item in a WPF ListBox control seems to have a bit of left
For each item in my application's settings, I've added text to its Description Property
I want to display a QListView where each item is a checkbox with some
My stackpanels have gaps between each item (TextBlocks). You can see through to whatever
I have lists of variable length where each item can be one of four
I have a list, each item of which has several things in it, including
I have a treeview that is bound to a collection and each item in
I'm working with TListView and I have successfully populated each item's caption and first
I have a menu structure that is supposed to highlight each item as it
I've got listbox that employs an item template. Within each item in the list,

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.