Culter + Date Format in MM/DD/YYYY Database - how to force a single format?

C

Chu

In playing with asp.net 2.0, I've been impressed with the
internationalization support that's built right in. It's great that I
can simply add a tag to my page's directive and it magically transforms
all dates into my end user's date format. However, it's causing a
problem that I've yet to find a cure for:

My server is located in the US, where we obviously use the date format
MM/DD/YYYY. I use DateTime.Now through my code which works great until
the client's system is setup to use another format, such as DD/MM/YYYY
-- then the database gets fed the wrong date format. Is there a way I
can tell, or format DateTime.Now back into a specific format for my
database?
 
S

Shawn

myDate.Tostring("MM/dd/yyyy")

Shawn

In playing with asp.net 2.0, I've been impressed with the
internationalization support that's built right in. It's great that I
can simply add a tag to my page's directive and it magically transforms
all dates into my end user's date format. However, it's causing a
problem that I've yet to find a cure for:

My server is located in the US, where we obviously use the date format
MM/DD/YYYY. I use DateTime.Now through my code which works great until
the client's system is setup to use another format, such as DD/MM/YYYY
-- then the database gets fed the wrong date format. Is there a way I
can tell, or format DateTime.Now back into a specific format for my
database?
 
C

Chu

Isn't there an easier way to do it? I'd have to go back to many places
in the code just to make that change.

I guess this brings up the point of best practices when using dates in
code. Generally speaking, how is it normally handled? Is there someone
to just get the server's "Now" time in the server's culture?
 

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,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top