2

In my MVC application I am selecting the company & doing my operations based on that. as you can see in the Image below::

Countries

Here the problem is with the Timezone based on the company I have selected. Because I have to Insert the Datetime for the current Timezone.

We know in C# there are Inbuild properties like ::

 DateTime.Now
 DateTime.UtcNow
 TimeZone.CurrentTimeZone

I just want the time based on companies selected from the above Dropdown in C#.

Please Help me on this, Thanks in Advance.

leppie
  • 115,091
  • 17
  • 196
  • 297
Rahul
  • 2,309
  • 6
  • 33
  • 60

2 Answers2

1

You can get it by using Date.getTimezoneOffset(). This links might helps you.

http://aspdotnet-naresh.blogspot.in/2013/05/aspnet-how-to-convert-to-different-time.html

get client machine timezone in asp.net mvc

http://www.w3schools.com/jsref/jsref_getTimezoneOffset.asp

Get the default timezone for a country (via CultureInfo)

Community
  • 1
  • 1
Ajay
  • 6,418
  • 18
  • 79
  • 130
  • the Link you have given http://aspdotnet-naresh.blogspot.in/2013/05/aspnet-how-to-convert-to-different-time.html Does this link considers the DST( Daylight saving Time)? – Rahul Mar 20 '14 at 07:32
  • Try that code. and check is it returing correct date. – Ajay Mar 20 '14 at 09:28
0

To start, I recommend http://nodatime.org, because they have some mapping functions from the more common Olson-format to the windows time zone format. Read more about this: Olson Time Zone Id to Windows Standard Format using Noda Time

To solve your problem, there are multiple options:

  1. Save the name of the timezon in Olson format in your database.
  2. Save the geolocation in your database. You can use the shape file with timezones to select the right timezone based on geolocations. http://efele.net/maps/tz/world/. There is also library to read this file: http://www.easygisdotnet.com/api/
Community
  • 1
  • 1
SebastianStehle
  • 2,409
  • 1
  • 22
  • 32