Same date in different time zone

Here’s how you could do what you are asking: // get a moment representing the current time var now = moment(); // create a new moment based on the original one var another = now.clone(); // change the offset of the new moment – passing true to keep the local time another.utcOffset(‘+05:30’, true); // log … Read more

ruby get Time in given timezone

A simpler, more lightweight solution: Time.now.getlocal(‘-08:00′) Time.now.getlocal(-28800) Well documented here. Update 2021.12.23: If you’ve got a tzdata timezone name like ‘US/Pacific’ instead of an offset and you’re willing to pull in the tzinfo gem, you could also do this (with thanks to both @chadoh and @kevin from below): require ‘tzinfo’ TZInfo::Timezone.get(‘US/Pacific’).now Not really the problem … Read more

Get name of time zone

Can I get the name of the time zone of the client by using jQuery? No. jQuery has only one date/time function, which is $.now(). If you meant JavaScript, the answer is still no. You can only obtain a time zone offset from date.getTimezoneOffset(). You can’t get a time zone – at least not in … Read more

How to convert datetime to timestamp using C#/.NET (ignoring current timezone)

At the moment you’re calling ToUniversalTime() – just get rid of that: private long ConvertToTimestamp(DateTime value) { long epoch = (value.Ticks – 621355968000000000) / 10000000; return epoch; } Alternatively, and rather more readably IMO: private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); … private static long ConvertToTimestamp(DateTime value) { … Read more

Set a default time zone for f:convertDateTime

JSF date/time converters defaults by specification to UTC timezone. If you want to use a different timezone, then you really need to specify it in the converter yourself. Or, if you have 100% control over the production runtime environment, then since JSF 2.0 you can set its system timezone to the desired timezone and add … Read more

How to have Maven show local timezone in maven.build.timestamp?

As already mentioned, in the current versions of Maven (at least up to version 3.3.+), the maven.build.timestamp property does not allow for timezone overrides. However, if you are okay with utilizing a different property name for your purposes, the build-helper-maven-plugin allows you to configure custom timestamps for a variety of purposes. Here is an example … Read more

Is there a reason for java.time.ZoneId not including an Enum of ZoneIds?

I believe it’s because the list of all possible timezones names can change regardless of Java version. Timezone information comes with Java installation (usually in the folder <java-home>/lib/zi, or in jre/lib/tzdb.dat file in newer versions). But this information can be updated without changing the Java version (using the Timezone Updater Tool). If the timezone data … Read more

Mysql FROM_UNIXTIME as UTC

You would be better off setting the time zone ahead of time: SET time_zone=”UTC”; select FROM_UNIXTIME(1277942400); The reason is that conversions involving a local time zone can be lossy. There is an example of this in the docs here (see the 4th paragraph under the UNIX_TIMESTAMP() section starting with “Note:”)

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)