Format string for NSDateFormatter to produce milli

2019-02-21 11:44发布

Since my date is well formatted now all there is left for me to do is to print milliseconds too.

I already tried setDateFormat yyyy/mm/dd hh:mm:ss:ms

That didn't work. Any advice?

2条回答
兄弟一词,经得起流年.
2楼-- · 2019-02-21 12:20

Try this format:

"yyyy/MM/dd HH:mm:ss.SSS"
查看更多
等我变得足够好
3楼-- · 2019-02-21 12:29

Try to use 'SS' specifier (with number of S's equal to number of digits you want to get - 3 in your case), e.g.

[formatter setDateFormat:@"yyyy/MM/dd hh:mm:ss:SSS"];
查看更多
登录 后发表回答