views:

42

answers:

2

i want to get date in 2 labels like this
Label1:-> Tuesday
Label2:-> 2 June 2010

how can i get this value?

+1  A: 
[label1 setText:@"Tuesday"];
[label2 setText:@"2 June 2010"];

Or did you need something different?

Dave DeLong
A: 

This code will get you the strings you require to set the labels:

NSDate *today = [NSDate date];
NSDateFormatter *weekdayFormatter = [[[NSDateFormatter alloc] init] autorelease];
NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
[formatter setDateFormat: @"d MMMM yyyy"];
[weekdayFormatter setDateFormat: @"EEEE"];
NSString *formattedDate = [formatter stringFromDate: today];
NSString *weekday = [weekdayFormatter stringFromDate: today];

The date formatters are controlled through this standard: Unicode Date Formats

jshier