Jump to content

Invalid Date format


Tegwin

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.