I'm doing a booking system using PHP and MySQL. my question is Can I store time without showing the seconds? for ex: 19:10, and store a date in the form of (Fri Nov 20th, 2020) using varchar. are these things work in a booking system?
Asked
Active
Viewed 24 times
1
-
6In a nutshell: don't. Use the proper datatype to store your data. You can handle the display concerns in your queries, or in your application code. – GMB Oct 30 '20 at 22:30
-
1Maybe this can help you : https://stackoverflow.com/questions/19152347/formatting-date-to-human-readable-format – Oct 30 '20 at 22:33
-
2If you store your dates using English formatting that's asking for trouble and will make your life full of unending misery. These will sort in order of `Fri`, `Mon`, `Sat`, `Sun`, `Thu`, `Tue`, `Wed`, then by `Apr`, `Aug`, `Dec`, `Feb`, `Jan`, `Jun`, `Jul`, `May`, `Mar` and so on which is complete nonsense. Use [ISO-8601](https://en.wikipedia.org/wiki/ISO_8601) formatting. These are sortable, trivial to do computations on, and go into `DATE` and `DATETIME` fields without a fuss. You can format these however you want, or however your *user wants* in the application layer. – tadman Oct 30 '20 at 22:59
-
thank you for the brief explanation. – YCoder Oct 30 '20 at 23:07