Jump to content

Recommended Posts

Invalid Date format

Hello I have set up a database in MySQL which uses the datetime for the columns. I have 2 seperate fields, one for date and one for time. when I display the information, I get the following information

 

Date 2002-11-09 00:00:00 Time 1899-12-30 20:50:00

 

The date in the first field is 2002-11-09 and the time in the second filed is 20:50:00 but the date field puts an additional time in as 00:00:00 and the time field has a date of 1899-12-30 .. How can I get rid of these. I want the date only in one field and the time only in the other...

Link to comment
https://forums.phpfreaks.com/topic/516-invalid-date-format/
Share on other sites

The other option is to not use a seperate data and seperate time column, but instead to use a Datetime column.

 

It\'s also better not to use keywords as the names of your columns. I\'d suggest instead that you have a column called for example:

 

created.

 

When inserting a value it could be insert into yourtbl (col1, col2, created) values (\'blah\', \'blah\', now());

 

It\'s easy enough via either MYSQL or php to seperate the date and time components from a date/time. The added advantage of using a datetime, is that *if* you need to do selects via date, it will be much more efficient. For example, you might have a query like:

 

select * from yourtbl where created > now()-1;

Link to comment
https://forums.phpfreaks.com/topic/516-invalid-date-format/#findComment-1736
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.