NSLocale* currentLocale = [NSLocale currentLocale];
[[NSDate date] descriptionWithLocale:currentLocale];
or use
NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
// or @"yyyy-MM-dd hh:mm:ss a" if you prefer the time with AM/PM
NSLog(@"%@",[dateFormatter stringFromDate:[NSDate date]]);
Related Contents:
- How to Check if an NSDate occurs between two other NSDates
- Sort NSArray of date strings or objects
- How do I get the current date in Cocoa
- Getting the last day of a month
- How to print out the method name and line number and conditionally disable NSLog?
- throwing an exception in objective-c/cocoa
- How do I convert NSMutableArray to NSArray?
- Difference between objectForKey and valueForKey?
- Hidden Features of Xcode
- NSString property: copy or retain?
- What is the best way to unit test Objective-C code?
- How do you print out a stack trace to the console/log in Cocoa?
- Execute a terminal command from a Cocoa app
- Best way to remove from NSMutableArray while iterating?
- What’s the Best Way to Shuffle an NSMutableArray?
- NULL vs nil in Objective-C
- What is the best way to solve an Objective-C namespace collision?
- Why are Objective-C delegates usually given the property assign instead of retain?
- NSString tokenize in Objective-C
- Is there a way to suppress warnings in Xcode?
- How to perform Callbacks in Objective-C
- Check whether or not the current thread is the main thread
- How do I make and use a Queue in Objective-C?
- NSString: isEqual vs. isEqualToString
- Getting an object from an NSSet
- What exactly is a so called “Class Cluster” in Objective-C?
- How can I dynamically create a selector at runtime with Objective-C?
- Make a two-digit string from a single-digit integer
- How to quit cocoa app when windows close? [duplicate]
- Is there a way to specify argument position/index in NSString stringWithFormat?
- Objective-C: Assertion vs. Exception vs. Error
- Objective-C Introspection/Reflection
- Rounding numbers in Objective-C
- How do I create a NSTimer on a background thread?
- What unit of time does timeIntervalSinceDate return?
- NSPredicate case-insensitive matching on to-many relationship
- Class method equivalent of -respondsToSelector:
- Number of occurrences of a substring in an NSString?
- Is there a literal syntax for mutable collections?
- Object allocate and init in Objective C
- Properties and Instance Variables in Objective-C
- Data doesn’t load in UITableView until I scroll
- Why are umbrella frameworks discouraged? [closed]
- Dependency injection framework for Cocoa? [closed]
- How to add hours to an NSDate?
- How to use kCGImagePropertyGIFImageColorMap or create a color table?
- In Cocoa do you prefer NSInteger or int, and why?
- How do you schedule a block to run on the next run loop iteration?
- Callbacks When an NSScrollView is Scrolled?
- const vs static NSStrings in Objective-C