why is some strange character in NSDate string
I am using below code to get date time. I will post them to server let dateFormatter = NSDateFormatter() dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss" let strDate = dateFormatter.stringFromDate(NSDate()) In server, I found there several log has strange data. it is encoded as "date": "\u0662\u0660\u0661\u0666-\u0660\u0664-\u0661\u0660 \u0661\u0668:\u0665\u0669:\u0664\u0663" I found them show as ٢٠١٦-٠٤-١٠ ١٨:٥٩:٤٣ in UTF16, what is the problem, it seems date format is correct, but why year-month-day hour:minitue:seconds become invalid. Thanks~
Just set the locale on the formatter: let dateFormatter = NSDateFormatter() dateFormatter.locale = NSLocale(localeIdentifier: "en_US_POSIX") en_US_POSIX is a standardized locale that will never change (even if the US were to change how it encodes things). As A-Live notes, these are valid digits and valid dates. They're just not Western Arabic digits (0123456789). They're Eastern Arabic digits (٠١٢٣٤٥٦٧٨٩). stringFromDate() uses the locale from the formatter. If you don't set one, it uses the system locale. If you want a particular one, set it. See QA1480 for full details.
These are totally valid year, month, day, etc: based on your code we can see that you've decided to accept the values of any locale, including non-arabic digits.
Meteor app: Difference Between Uploading Images from Iphone than Computer?
NodeJS(SocketIO) authentication token
When writing to text file (appending) the last value I write replaces all previous values
How to use WebP image in UIImageView Swift
How to get rid of the glitch that occurs right after pressing the back button?
Distance between two UIButtons according to screen size? [closed]
Creating ssl public and private key pair in ios app
How to Renaming a Project or App in XCode? [duplicate]
ios - how to have Multiple lines of NSAttributedString
Granting permission for the calendar without showing ios builtIn alertView
iOS JSON Parsing, Format Issues
UIButton in scrollView position unexpected
cross building binutils 2.25.1 for iOS8.4 (arm64-apple-darwin14.0.0)
SWIFT: Modal Segue From TableViewCell (Prototype Cell) Is Not Working
NSDictionary is nil when I decode with NSKeyedUnarchiver even when passing valid data object
Why are my Parse API requests increasing rapidly each day?