Date format

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
 
N

northof40

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.
 
T

Tony WONG

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.
 
R

Rad [Visual C# MVP]

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,067
Latest member
HunterTere

Latest Threads

Top