Java Convert GMT/UTC to Local time doesn’t work as expected

I also recommend using Joda as mentioned before. Solving your problem using standard Java Date objects only can be done as follows: // **** YOUR CODE **** BEGIN **** long ts = System.currentTimeMillis(); Date localTime = new Date(ts); String format = “yyyy/MM/dd HH:mm:ss”; SimpleDateFormat sdf = new SimpleDateFormat(format); // Convert Local Time to UTC (Works … Read more

NSTimeZone: Any difference between “UTC” and “GMT”?

According to the docs, CFTimeZone (and by extension, NSTimeZone) uses time zone names, abbreviations, GMT offset, and DST information from the TZ (or “Olsen”) Database. Looking at the source, you’ll see that while semantically “GMT” and “UTC” are quite distinct, in practice they’re no different: “GMT” is just a zero offset timezone. Update: While this … Read more

Updating time offset with moment().utcOffset()

The main issue is that you are passing the offset as a string instead of a number. moment.utc(“2015-10-01 01:24:21”).utcOffset(“-240”).format(‘YYYYMMDD HHmmss ZZ’) // “20151001 012421 +0000” moment.utc(“2015-10-01 01:24:21”).utcOffset(-240).format(‘YYYYMMDD HHmmss ZZ’) // “20150930 212421 -0400” When you have an offset in terms of minutes, then you must use the numeric form. You can always convert it: moment.utc(“2015-10-01 … Read more

Converting an ISO 8601 timestamp into an NSDate: How does one deal with the UTC time offset?

No need to remove the :’s. To handle the “00:00” style timezone, you just need “ZZZZ”: Swift let dateString = “2014-07-06T07:59:00Z” let dateFormatter = NSDateFormatter() dateFormatter.locale = NSLocale(localeIdentifier: “en_US_POSIX”) dateFormatter.dateFormat = “yyyy-MM-dd’T’HH:mm:ssZZZZ” dateFormatter.dateFromString(dateString) Objective-C NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; dateFormat.locale = [[NSLocale alloc] initWithLocaleIdentifier:@”en_US_POSIX”]; NSString *input = @”2013-05-08T19:03:53+00:00″; [dateFormat setDateFormat:@”yyyy-MM-dd’T’HH:mm:ssZZZZ”]; //iso 8601 format NSDate … Read more

Convert UTC to current locale time

It has a set timezone method: SimpleDateFormat simpleDateFormat = new SimpleDateFormat(“yyyy-MM-dd HH:mm:ss”); simpleDateFormat.setTimeZone(TimeZone.getTimeZone(“UTC”)); Date myDate = simpleDateFormat.parse(rawQuestion.getString(“AskDateTime”)); all done!

Javascript JSON Date parse in IE7/IE8 returns NaN

In older browsers, you can write a function that will parse the string for you. This one creates a Date.fromISO method- if the browser can natively get the correct date from an ISO string, the native method is used. Some browsers got it partly right, but returned the wrong timezone, so just checking for NaN … Read more

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