[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Best method for converting NSDates into different time zones?
From: |
David Wetzel |
Subject: |
Best method for converting NSDates into different time zones? |
Date: |
Wed, 18 Nov 2009 22:06:07 -0800 |
Hi guys,
I have a database with dates in CET and would like to preset them in the local
time of the users.
It is a web app.
This is the only way I was able to convert between time zones, but that should
be possible with DateFormatters too, right?
NSCalendarDate * date = [NSDate date]; // just for testing
NSLog([[date dateWithCalendarFormat:@"%d.%m.%Y %H:%M:%S %z"
timeZone:[NSTimeZone
timeZoneWithName:@"Europe/Berlin"]] descriptionWithLocale:nil]);
NSLog([[date dateWithCalendarFormat:@"%d.%m.%Y %H:%M:%S %z"
timeZone:[NSTimeZone
timeZoneWithName:@"America/Vancouver"]] descriptionWithLocale:nil]);
The output of the above is:
2009-11-19 06:59:10.084 NSTimeZoneTest[3027] 19.11.2009 06:59:09 +0100
2009-11-19 06:59:10.104 NSTimeZoneTest[3027] 18.11.2009 21:59:09 -0800
Cheers
David
- Best method for converting NSDates into different time zones?,
David Wetzel <=