gchq
Well-known member
- Joined
- Dec 14, 2007
- Messages
- 168
- Programming Experience
- 10+
Hi there
We have a desktop WinApp that saves data to our server via a WebService
Our servers are set to UTC
Question is - what is the best method of saving dates locally and then retrieving them?
I have tried several methods like
to save the date
and
to display the date...
But to no avail!
Any ideas on the best method?
Thanks
==========================================
Just to add a bit of history
At first dates were saved and displayed 'as is' with no conversion (a string, is a string, is a string... what needs to be converted?)
Then I discovered that data saved with a GB regional setting was very helpfully (not) showing as the day before at 16:00 (PST), sooooo..
... seemed to sort out the problem, and we had peace within developer land!
Then it was discovered that entering an item on the PST PC before 08:00 would display the date as the day before...
Since then it's been all downhill with every new method attempted...
We have a desktop WinApp that saves data to our server via a WebService
Our servers are set to UTC
Question is - what is the best method of saving dates locally and then retrieving them?
I have tried several methods like
VB.NET:
DateTime.Parse(InputDate).ToUniversalTime
to save the date
and
VB.NET:
DateTime.Parse(InputDate).ToLocalTime
to display the date...
But to no avail!
Any ideas on the best method?
Thanks
==========================================
Just to add a bit of history
At first dates were saved and displayed 'as is' with no conversion (a string, is a string, is a string... what needs to be converted?)
Then I discovered that data saved with a GB regional setting was very helpfully (not) showing as the day before at 16:00 (PST), sooooo..
VB.NET:
Public Function ReturnLocalDateFormat(ByVal InputDate As Date) As String
InputDate = DateTime.Parse(InputDate).ToUniversalTime
Dim vCulture As String = System.Globalization.CultureInfo.CurrentCulture.ToString
Dim vReturnDate As String = ""
Select Case vCulture
Case "en-US"
vReturnDate = Format(InputDate, "MM/dd/yyyy")
Case "en-GB"
vReturnDate = Format(InputDate, "dd/MM/yyyy")
Case Else
vReturnDate = Format(InputDate, "dd/MM/yyyy")
End Select
Return vReturnDate
End Function
... seemed to sort out the problem, and we had peace within developer land!
Then it was discovered that entering an item on the PST PC before 08:00 would display the date as the day before...
Since then it's been all downhill with every new method attempted...
Last edited: