Dave C
Dave C

Reputation: 1652

How do I change the Date Format of a .net SOAP request?

I'm using a WSDL that expects a DateTime parameter for one of the methods. When .NET serializes my call, it creates a date parameter like this:

2010-1-1T10:00:00.00

This looks like the serializer is using a date format of "s". I need a different format, namely one with the timezone offset:

2010-1-1T10:00:00.00 -4:00

How do I specify the date format I want the serializer to use? (C# or VB.NET)

Upvotes: 5

Views: 4913

Answers (2)

Steav
Steav

Reputation: 1486

Usually this would be done by passing Time / Date in the UTC (Universal Time Coordinated) format... meaning: Worldtime and putting the timezone (if needed) in a seperate parameter.

See: http://msdn.microsoft.com/en-us/library/system.datetime.touniversaltime%28VS.71%29.aspx

Upvotes: 0

to StackOverflow
to StackOverflow

Reputation: 124776

If the timezone offset is for your current timezone, you should check that your DateTime instance has its Kind property set to DateTimeKind.Local. If not, you can force it as follows:

DateTime myDateTime;
...
myDateTime = myDateTime.SpecifyKind(myDateTime, DateTimeKind.Local);

Upvotes: 2

Related Questions