Search code examples
xcodeios7

How to get current time along with the Timezone in XCode?


I tried this :

    NSDate *date = [NSDate date];
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setDateFormat:@"YYYY-MM-dd hh:mm:ss TZD"];
    NSString *dateString = [dateFormat stringFromDate:date];
    NSLog(@"Current Date : %@",dateString);

and the result I get is Date and Time but not the Timezone.


Solution

  • @Vaibhav you have to use time zone like this

    NSTimeZone *timeZone = [NSTimeZone localTimeZone];
    

    refer this link

    Get the time and date of selected time zone?