adiemeer
asked on
How to choose the right date format
Hello,
I do have a website where I want to display the last date an user logged in. This information I have stored in a database. At this moment I use the pattern yyyy-MM-ddTHH:mm:ss.fff
to identify the date. The pattern works well if the stored date is for example 2013-02-15T12:11:41.203. However if the stored date is 2013-02-15T12:11:41.20 this doesn't work well.
How do I have to change the pattern yyyy-MM-ddTHH:mm:ss.fff to read both the dates well? I tried yyyy-MM-ddTHH:mm:ss.ff0, but that didn't work.
Thanks!
Regards Arne
I do have a website where I want to display the last date an user logged in. This information I have stored in a database. At this moment I use the pattern yyyy-MM-ddTHH:mm:ss.fff
to identify the date. The pattern works well if the stored date is for example 2013-02-15T12:11:41.203. However if the stored date is 2013-02-15T12:11:41.20 this doesn't work well.
How do I have to change the pattern yyyy-MM-ddTHH:mm:ss.fff to read both the dates well? I tried yyyy-MM-ddTHH:mm:ss.ff0, but that didn't work.
Thanks!
Regards Arne
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
How is it I posted the answer, but got none of the points?
It sounds like you're storing the date/time in a string format. Standard practice is to store date/times in the database native format. When you query the data, formatting functions (which can output almost any format) convert the internal date/time to whatever format you want. The functions are a little different depending on what database you're using. Which DB are you using?
Regards,
Aielloj