[Solved] how to get user local machine time zone in c#

TimeZone.CurrentTimeZone is used for the time zone on the computer where the code is executing. Check these links: http://msdn.microsoft.com/en-us/library/system.timezone.currenttimezone.aspx http://msdn.microsoft.com/en-us/library/system.timezoneinfo.local.aspx 2 solved how to get user local machine time zone in c#

[Solved] Format date by provided time zone in java [duplicate]

Use the modern Java date and time classes for everything that has got to do with dates or times. DateTimeFormatter usFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT) .withLocale(Locale.US); System.out.println(date.format(usFormatter)); DateTimeFormatter deFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT) .withLocale(Locale.GERMANY); System.out.println(date.format(deFormatter)); This will print something like 6/27/17 27.06.17 It’s not exactly the formats you asked for, but it’s the formats Java thinks are appropriate for … Read more

[Solved] How to get time from user with respect to timezone

String userTimeZone = “Asia/Samarkand”; String userDate = “2018-07-05”; ZoneId zone = ZoneId.of(userTimeZone); Instant dbInstant = LocalDate.parse(userDate) .atStartOfDay(zone) .toInstant(); System.out.println(dbInstant); This prints what you had expected: 2018-07-04T19:00:00Z I don’t know MongoDB’s JDBC driver, but I assume it would be happy to accept an Instant and store it in UTC in the database. GMT+05:00 is not really … Read more

[Solved] Programmatically get the time at clock-change [closed]

To find out DST transitions, you could access Olson timezone database e.g., to find out the time of the next DST transition, in Python: #!/usr/bin/env python from bisect import bisect from datetime import datetime import pytz # $ pip install pytz def next_dst(tz): dst_transitions = getattr(tz, ‘_utc_transition_times’, []) index = bisect(dst_transitions, datetime.utcnow()) if 0 <= … Read more

[Solved] In ASP.NET MVC2, convert time user’s timezone. How to get timezone info? [closed]

You’re passing values that aren’t even of the right data type. Read up on TimeZoneInfo so you know how to use it properly. Also read: Why you shouldn’t use DateTime.Now The timezone tag wiki DST and Time Zone Best Practices Also understand that somewhere here you actually have to know the user’s time zone. Just … Read more

[Solved] Java Date and utcTimeOffset [closed]

java.time, the modern Java date and time API ZoneId danishTime = ZoneId.of(“Europe/Copenhagen”); DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern(“uuuuMMddHHmmss”); DateTimeFormatter offsetFormatter = DateTimeFormatter.ofPattern(“XX”); String dateTimeString = “20180730131847”; String offsetString = “+0200”; ZoneOffset offset = ZoneOffset.from(offsetFormatter.parse(offsetString)); ZonedDateTime dateTime = LocalDateTime.parse(dateTimeString, dateTimeFormatter) .atOffset(offset) .atZoneSameInstant(danishTime); System.out.println(“Danish time: ” + dateTime); Output from this code is: Danish time: 2018-07-30T13:18:47+02:00[Europe/Copenhagen] The time zone … Read more