0

I am facing a very strange behaviour in my app. This code:

var timestamp: Date?
...
timestamp?.toString(format: "yyyyMMddHHmmss")

produces some unexpected results. In 99.99% of cases everything works fine and the correct string is sent to my server. However, there was an extremely rare situation when the result which came to my server was

2018020671122 dop.

dop. is probably a Czech equivalent of AM.

I don't understand why this happens. There is no tt in my format and it is explicitly stated that I want two digits for hours, not just one. My code works fine on many devices, but it keeps producing the result above on a single device (iPhone 5s, iOS 10). I cannot reach this particular device (it belongs to one of my customer out there). Any idea?

vojta
  • 5,591
  • 2
  • 24
  • 64
  • check for timezone – Mahendra Feb 21 '18 at 10:09
  • 2
    That device is probably set to 12h time formatting. You are not setting locale to POSIX, therefore the format is overwritten from `HH` to `hh`. See the linked QA, especially the technical note https://developer.apple.com/library/content/qa/qa1480/_index.html – Sulthan Feb 21 '18 at 10:11

0 Answers0