LanceT Posted January 29, 2007 Share Posted January 29, 2007 Lets say you are posting a news post, is there a way to insert the days date into your mysql database? I know of the curdate() function, but is there a better way to do this? The way the date is formatted in curdate() is not what I want. Quote Link to comment Share on other sites More sharing options...
AndyB Posted January 29, 2007 Share Posted January 29, 2007 What's important is almost always how the date is formatted when it's displayed. Provided that you store something rational in an appropriate datatype field, you should have no problems in converting it to whatever date display format you want ... and you'll be able to process records in your database by date as and when it's necessary. Quote Link to comment Share on other sites More sharing options...
LanceT Posted January 29, 2007 Author Share Posted January 29, 2007 thats not really my problem, but I want it to insert TODAY's current date. I know that I could insert 12707 and format it to January 27, 2007, but I want it to be able to recognize what today's current date is.So are you saying this is possible with the curdate() function or what? Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 29, 2007 Share Posted January 29, 2007 now() Quote Link to comment Share on other sites More sharing options...
SweetLou Posted January 30, 2007 Share Posted January 30, 2007 You could make the column as a timestamp, you won't need to enter the data, it will automatically add the current date. But, if you ever modify the record, the date will change again. Quote Link to comment Share on other sites More sharing options...
fenway Posted January 30, 2007 Share Posted January 30, 2007 1) Never use TIMESTAMP.2) The MySQL date format is SQL-99 standard -- and you always want that format... ALWAYS! Quote Link to comment Share on other sites More sharing options...
SweetLou Posted January 30, 2007 Share Posted January 30, 2007 Never have used TIMESTAMP, but why not? Quote Link to comment Share on other sites More sharing options...
LanceT Posted January 31, 2007 Author Share Posted January 31, 2007 [quote author=fenway link=topic=124488.msg517274#msg517274 date=1170181657]1) Never use TIMESTAMP.2) The MySQL date format is SQL-99 standard -- and you always want that format... ALWAYS![/quote]what is SQL-99 standard? Quote Link to comment Share on other sites More sharing options...
fenway Posted January 31, 2007 Share Posted January 31, 2007 [quote author=SweetLou link=topic=124488.msg517541#msg517541 date=1170199366]Never have used TIMESTAMP, but why not?[/quote]First, the date range is limited, so that's annoying -- second, it has also sorts of magical, half-documented and entirely undesirable features. Third, DATETIME is just more logical for so many reasons.[quote author=LanceT link=topic=124488.msg517566#msg517566 date=1170202633][quote author=fenway link=topic=124488.msg517274#msg517274 date=1170181657]1) Never use TIMESTAMP.2) The MySQL date format is SQL-99 standard -- and you always want that format... ALWAYS![/quote]what is SQL-99 standard?[/quote]YYYY-MM-DD... not only is it the only unambigious format, but it also sorts lexically. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.