[Solved] Convert time format to UTC format [closed]

Try This. NSString *strIncomingDate = @”29-Mar-2018 05:58:33″; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@”UTC”]]; [dateFormat setDateFormat:@”dd-MMM-yyyy hh:mm:ss”]; NSDate *date = [dateFormat dateFromString:strIncomingDate]; NSDateFormatter *dateFormat1 = [[NSDateFormatter alloc] init]; [dateFormat1 setTimeZone:[NSTimeZone timeZoneWithAbbreviation:@”UTC”]]; [dateFormat1 setDateFormat:@”yyyy-MM-dd’T’HH:mm:ss’Z'”]; NSString *strDesire = [dateFormat1 stringFromDate:date]; 10 solved Convert time format to UTC format [closed]

[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