Date format

  • Thread starter Thread starter Tony WONG
  • Start date Start date
T

Tony WONG

The date format (control panel) of testing (VS2005) and production platform
are yyyy/mm/dd.

i run preview from testing (VS2005). The date format is yyyy/mm/dd

however, when i put the code to production platform. The date format is
dd/mm/yyyy

what should i look to? Thanks a lot.

tony
 
The date format (control panel) of testing (VS2005) and production platform
are yyyy/mm/dd.

i run preview from testing (VS2005). The date format is yyyy/mm/dd

however, when i put the code to production platform. The date format is
dd/mm/yyyy

what should i look to? Thanks a lot.

tony

I'm assuming you want all users of your app to use the same date/time
format ? That is you don't want americans to mm/dd/yy and europeans to
see dd/mm/yy ?

If that's the case I would suggest something like this :

sOut = string.Format("{0:yyyy}", (DateTime)objIn)

.... (only obviously with your choice of date format - that one will
only give you the year component of the date). You'll need to be ready
to 'unformat' date/time strings which come back from 'add'/'edit' type
forms in whatever format you've chosen.

Relying on the servers default date/time formatting is not a good idea.
 
Thanks for your advice.

northof40 said:
I'm assuming you want all users of your app to use the same date/time
format ? That is you don't want americans to mm/dd/yy and europeans to
see dd/mm/yy ?

If that's the case I would suggest something like this :

sOut = string.Format("{0:yyyy}", (DateTime)objIn)

... (only obviously with your choice of date format - that one will
only give you the year component of the date). You'll need to be ready
to 'unformat' date/time strings which come back from 'add'/'edit' type
forms in whatever format you've chosen.

Relying on the servers default date/time formatting is not a good idea.
 
I'm assuming you want all users of your app to use the same date/time
format ? That is you don't want americans to mm/dd/yy and europeans to
see dd/mm/yy ?

If that's the case I would suggest something like this :

sOut = string.Format("{0:yyyy}", (DateTime)objIn)

... (only obviously with your choice of date format - that one will
only give you the year component of the date). You'll need to be ready
to 'unformat' date/time strings which come back from 'add'/'edit' type
forms in whatever format you've chosen.

Relying on the servers default date/time formatting is not a good idea.

Better yet, you can set the culture in the web.config and that way
avoid changing any of your code.
 
Back
Top