• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Getting the GMT time
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting the GMT time


  • Subject: Re: Getting the GMT time
  • From: Brian Bergstrand <email@hidden>
  • Date: Fri, 16 Apr 2004 15:53:09 -0500

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Here's an inline I use to get the GMT time.

static __inline NSCalendarDate* GMTDate(NSDate *d)
{
return ([d dateWithCalendarFormat:nil timeZone:[NSTimeZone
timeZoneWithAbbreviation:@"GMT"]]);
}

To get the current time, use the following:

id gmt;
gmt = GMTDate([NSDate date]);

HTH.

On Apr 16, 2004, at 3:11 PM, Frederick C. Lee wrote:

> Greetings:
>
> Is there a simple way to get the GMT time?
>
> The only viable way I know is to get the time offset from the local
> time zone and compute it.
>
> But is there a direct way to actually get the GMT?
>
> The following snippet I've tried but I get a nil result:
>
> NSTimeZone *t = [[NSTimeZone alloc] init];
>
> if ([t initWithName:@"GMT"] == nil) {
> NSLog(@"***** NULL Time zone???");
> }
>
> NSCalendarDate *GMTtime = [NSCalendarDate calendarDate];
> [GMTtime setTimeZone:t];
>
>
>
> I'm lost here.
>
> Regards,
>
> Ric.
>
Brian Bergstrand <http://www.bergstrand.org/brian/>, AIM: triryche206
PGP Key: <http://www.bergstrand.org/brian/misc/public_key.txt>
The word 'politics' is derived from the word 'poly', meaning 'many',
and the word 'ticks', meaning 'blood sucking parasites'. - Larry
Hardiman
As of 03:50:04 PM, iTunes is playing "Losing Myself" from "Tribe" by
"Queensrche"

-----BEGIN PGP SIGNATURE-----
Version: PGP 8.0.3

iQA/AwUBQIA5tXnR2Fu2x7aiEQJyFgCfcKmr+4i8uwDMATDzQi0o9WcZPokAnj92
xdXxB6f64I0yY30pNjHrDP3N
=VpU2
-----END PGP SIGNATURE-----
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


  • Follow-Ups:
    • Re: Getting the GMT time
      • From: Steve Palmer <email@hidden>
References: 
 >Getting the GMT time (From: "Frederick C. Lee" <email@hidden>)

  • Prev by Date: Re: Simple question: getting 'locale' dictionary for NSCalendarDate class routine
  • Next by Date: Re: Best place to hide license files
  • Previous by thread: Getting the GMT time
  • Next by thread: Re: Getting the GMT time
  • Index(es):
    • Date
    • Thread