I'm making a web based project management application using MySQL and PHP that uses JS (Jquery) in the front end. The user has to input a date and optionally time as well.
However I'm not sure how I should go about inserting and storing the date and converting it back to human readable form in the application.
Thanks in advance, RayQuang
Always use the standard Date/Time types for the respective situation.
In MySQL, use one of the appropriate Date and Time Type. Don't just blindly use one type. If you're storing a date, don't use a timestamp. If you're storing a timestamp, don't use a date. Use the proper type and be done.
In PHP, you can use an integer (parse from mysql's type with strtotime()
.
Talking with JS, I'd suggest using RFC 2822 date format, since it's standard. That way, you're communicating externally using a standard date/time format (which is non-ambiguous).
Store as timestamp.timestamp contain both date and time. and it will be best way to store date and time .
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With