RayT
asked on
Retrieve Client's Date & Time
Is there a way to retrieve the client's date and time using ASP.NET 2.0?
http://www.codeproject.com/KB/scripting/datumivreme.aspx
Check this:
http://www.daniweb.com/forums/thread32473.html
http://www.daniweb.com/forums/thread32473.html
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Dim strD As String = Request("cdatetime") '^^
ASKER
Gnoon,
I tried your code and it returns a time that is 5 hours ahead of my time. I was expecting to see the same date and time that is on my PC.
How do I get it to do that?
I tried your code and it returns a time that is 5 hours ahead of my time. I was expecting to see the same date and time that is on my PC.
How do I get it to do that?
I guess it's converted to UTC while parsing because we does not provide any time zome information in the format for the parsing.
Furthermore, as I see your time zone above it is GMT-05:00. Also, en-US (as we used it for parsing) is GMT-05:00. So, I'm not sure here which one is the cause of 5 hours ahead.
I think it's about DateTimeStyles of parsing. Unfortunately, I do not have the environment to test it.
I think using AssumeLocal option is forcing it to not convert to UTC again (because the javascript already did it).
Try
clientDateTime = System.DateTime.ParseExact (strD, "ddd, dd MMM yyyy HH:mm:ss 'UTC'", culture, _
DateTimeStyles.AssumeLocal )
Catch
End Try
Furthermore, as I see your time zone above it is GMT-05:00. Also, en-US (as we used it for parsing) is GMT-05:00. So, I'm not sure here which one is the cause of 5 hours ahead.
I think it's about DateTimeStyles of parsing. Unfortunately, I do not have the environment to test it.
I think using AssumeLocal option is forcing it to not convert to UTC again (because the javascript already did it).
Try
clientDateTime = System.DateTime.ParseExact
DateTimeStyles.AssumeLocal
Catch
End Try
ASKER
Thanks