I have a C# .NET Windows application. I am using the Partner API to interact with Salesforce. I want to get the current date and time based on logged in user's timezone in my .NET Windows application.

Basically, in my Windows application, I am fetching data from Salesforce using the API and printing that data into a Word file. In the Word file, I want the current date and time to display, but the current date and time should be based on the Salesforce User's timezone.

  • This might help - link Commented Feb 23, 2017 at 12:48
  • This will not help because I want current date and time of logged in user in my c# application.
    – rakesh
    Commented Feb 23, 2017 at 12:50
  • Can you please elaborate what is it that you want?
    – Samir
    Commented Feb 23, 2017 at 13:50

1 Answer 1


When you login to an org using the Partner WSDL and the SOAP API login() function, you can access the user's time zone using the resulting LoginResult object:

login["result"]["userInfo"]["userTimeZone"] // America/Mazatlan

Notice that the time zone is formatted using the tz database naming convention.

Since you are using C# .NET, I would recommend using the Noda Time API for .NET, which will help you obtain the current time from the time zone string returned in the result:

var local = LocalDateTime.FromDateTime(DateTime.Now);
var zone = DateTimeZoneProviders.Tzdb["America/Mazatlan"];
var zoned = local.InZoneLeniently(zone);

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .