Jump to content

Recommended Posts

hi

 

lets say im making an archive database in mysql

 

each article has a date

 

how do i need to imput the date in mysql

 

in 3 different columns(day, month, year) or just one column

 

if later i want to have the articles be in chronological order when i look at them on my website?

 

which is more efficient and easy?

 

what do u recommend?

 

and is there some code for putting the articles in chronological order?

 

thank you

Link to comment
https://forums.phpfreaks.com/topic/56755-solved-mysql-dates/
Share on other sites

no the mysql date column is best to use because any way you deal with a date it will be testing in a format YYYY/MM/DD which is the format you put in.  To order just when you run a query use the line ORDER BY `Datefield` at the end of it (past the WHERE part). 

 

You can search for stuff in your table that was say last month by using the mkdate() function.  its pretty simple to use and it will be way easier than testing 3 columns, plus as an optimization its always best to reduce number of fields

Link to comment
https://forums.phpfreaks.com/topic/56755-solved-mysql-dates/#findComment-280273
Share on other sites

Personally I prefer the use of timestamps over the MySQL standard of YYYY/MM/DD. Timestamps can be outputted however you like with PHP, and you can output them in order too. The MySQL version is easier to calculate differences etc. It's all down to personal preference really...

Link to comment
https://forums.phpfreaks.com/topic/56755-solved-mysql-dates/#findComment-280276
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.