Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Format string for NSDateFormatter to produce milliseconds

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?

like image 419
h4wkeye Avatar asked Apr 15 '11 10:04

h4wkeye


2 Answers

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"];
like image 122
Vladimir Avatar answered Nov 10 '22 01:11

Vladimir


Try this format:

"yyyy/MM/dd HH:mm:ss.SSS"
like image 38
Savitha Avatar answered Nov 10 '22 01:11

Savitha