Current Date & Time in Objective C

In this tutorial , i will tell you about NSDate and NSDateFormatters .
NSDate is inbuilt Objective c function which is used to find current date and time .

NSDateFormatter is used to format the date and time .eg :- MM/DD/YYYY hh:mm:ss.


TO FIND CURRENT DATE , ADD FOLLOWING CODE TO YOUR PROJECT :



Code is explained in comments.


Other date formats are as follows :


            Date Formats         Examples
M/d/y23/7/1993
MM/dd/yy23/07/93
MMM d, ''yyNov 4, '12
MMMMNovember
ESun
EEEESunday
'Week' w 'of 52'Week 45 of 52
'Day' D 'of 365'Day 309 of 365
QQQQ4
QQQQ4th quarter
m 'minutes past' h9 minutes past 8
h:mm a8:09 PM
HH:mm:ss's'20:09:00s
HH:mm:ss:SS20:09:00:00
h:mm a zz8:09 PM C
h:mm a zzzz8:09 PM Central Standard Time
yyyy-MM-dd HH:mm:ss Z2012-11-04 20:09:00 -0600

Thank You :)

Comments

Popular Posts