• 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: NSCalenderDate (Patel, Nilesh M)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSCalenderDate (Patel, Nilesh M)


  • Subject: Re: NSCalenderDate (Patel, Nilesh M)
  • From: Lorenzo <email@hidden>
  • Date: Tue, 25 May 2004 17:59:22 +0200

Hi,
you should get the current date/time this way:
NSCalendarDate *nowDateTime = [NSCalendarDate calendarDate];

then you can transform "nowDateTime" to a simple NSString this way:
NSString *fullDateTimeString = [nowDateTime description];

but probably you need to customize the date/time string by yourself.
If so, you can get a custom date/time string this way:

NSString *dateFormat = @"Now is: %A, %B %d, %Y - %H:%M:%S";
NSString *customDateTimeString = [nowDateTime
descriptionWithCalendarFormat:dateFormat];

And you will get somethisng like:
@"Now is: Monday, May 24, 2004 - 08:35:59"

In "dateFormat" you can write whatever before and after any parameter.
For example:
the parameter %Y means: year with century (such as 2004)
the parameter %d means: the day of the month as a decimal number (01-31)
so if you define the variable dateFormat as
@"The current year is %Y";
you will get the string
@"The current year is 2004"

All the specifiers descriptions for the date format are on your disk at:
file:///Developer/Documentation/Cocoa/Conceptual/DataFormatting/Concepts/Dat
eFormatters.html#//apple_ref/doc/uid/20000194/CJBFEHBD


Best Regards
--
Lorenzo
email: email@hidden


> Message: 13
> Subject: NSCalenderDate
> Date: Tue, 25 May 2004 09:39:40 -0400
> From: "Patel, Nilesh M" <email@hidden>
> To: email@hidden
>
> I am new to cocoa and have developed a texteditor and was wondering if there
> is a way where I can enter the date/time (NSCalenderDate) after I am done
> typing a letter, memo, note, etc. I was thinking about setting it up as an
> Action button? if so how?
_______________________________________________
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:
    • How to get date string formats in System International Preferences
      • From: Satoshi Matsumoto <email@hidden>
  • Prev by Date: Re: NSCalenderDate
  • Next by Date: Re: NSURLRequest and HTTP PUT?
  • Previous by thread: Re: NSCalenderDate
  • Next by thread: How to get date string formats in System International Preferences
  • Index(es):
    • Date
    • Thread