DateTime trouble

  • Thread starter Thread starter Shawn
  • Start date Start date
S

Shawn

Hi.
I can't figure out how to solve this problem, so if anyone here can help me
I will be forever grateful.
I have a web application, which is placed on two different servers. One of
the servers has the following date and time formatting set in regional
options in the control panel:
Date: dd.MM.yyyy Time: HH:mm:ss
The other one has this formatting:
M/dd/yyyy H:mm:ss

Now, I'm getting a date out of my DB. Not a date and a time, just the date.
I've specified it to be on this format: dd.MM.yyyy
This is what causes the problem, because the second server doesn't recognize
it as a valid date. How can I make the server recognize it as a valid date
without changing the regional options?

Thanks,
Shawn
 
How does your datetime data flows from one server to another server
What's the code causes problem?
 
Are you passing the date out of your DB as a string? Can you keep it as a
date instead? Otherwise, you may have to parse it yourself based on the
local settings. You could also try date.parse to see if it will do what you
want.
 
Yes the date is passed out as a string. I cannot keep it as a date unless I
want it to be passed out according to the date time format in Regional
Options.

I've tried just about everything. Date.Parse causes an exception because
the server doesn't recognize dd.MM.yyyy as a valid date.

Do you know how I get the date time formatting used by the system? Is there
a method or a property somewhere that will return, in this case, M/dd/yyyy
H:mm:ss ?

Shawn


Are you passing the date out of your DB as a string? Can you keep it as a
date instead? Otherwise, you may have to parse it yourself based on the
local settings. You could also try date.parse to see if it will do what you
want.
 
Never mind.. Insted of selecting the date using the date format I wanted to
show in my application, I selected it in it's native format and showed it in
my application using date.tostring("dd.MM.yyyy"). That way the system
recognized it as a date and I could perform datetime operations on it.

Shawn
 
Back
Top