Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 7th, 2012  |  syntax: None  |  size: 0.89 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Set NSDate TimeZone?
  2. NSString *dateString = [[webSentence child:@"DateTime"].text stringByReplacingOccurrencesOfString:@"T" withString:@" "];
  3.     NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  4.     [dateFormatter setDateFormat:@"yyyy-mm-dd HH:mm:ss"];
  5.     [dateFormatter setTimeZone:[NSTimeZone timeZoneWithName:@"Europe/Budapest"]];
  6.  
  7.     NSDate *date = [[NSDate alloc] init];
  8.     date = [dateFormatter dateFromString:dateString];
  9.        
  10. NSString *dateString = @"2011-09-02 17:49:54";
  11. NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
  12. NSTimeZone *tz = [NSTimeZone timeZoneWithName:@"Europe/Budapest"];
  13. [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
  14. [dateFormatter setTimeZone:tz];
  15.  
  16. NSDate *date = [dateFormatter dateFromString:dateString];
  17. NSLog(@"%@", [dateFormatter stringFromDate:date]);
  18. NSLog(@"%@", [date descriptionWithCalendarFormat:nil timeZone:tz locale:nil]);