How can I get the current date, and format it like "20/12/2010"?
Note: To insert only the current date into the textbox, please enter this formula: =Text(today(),"dd/mm/yyyy") into the linked cell A1.
Use NSDate and NSDateFormatter.
NSDate *today = [NSDate date]; NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init]; [dateFormat setDateFormat:@"dd/MM/yyyy"]; NSString *dateString = [dateFormat stringFromDate:today]; NSLog(@"date: %@", dateString);
See also.
Break it down.
How do I get the current date? See NSDate.
How do I format a date in a specific format? See NSDateFormatter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With