Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

.net

soap

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)

like image 882
Dave C Avatar asked Nov 05 '22 13:11

Dave C


1 Answers

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);
like image 70
Joe Avatar answered Nov 15 '22 11:11

Joe