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

  • Thread starter Thread starter Chu
  • Start date Start date
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?
 
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?
 
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?
 
Back
Top