ios - NSDateFormatter: error in converting date -


i have got following time stamp in milliseconds:

    nsdate * date = [nsdate datewithtimeintervalsince1970:1470524933.923123];     nsdate * date2 = [nsdate datewithtimeintervalsince1970:1470666561.000];      nsdateformatter *dateformatter = [[nsdateformatter alloc] init];     [dateformatter setdateformat:@"yyyy-mm-dd 'at' hh:mm:ss"];     nsstring * dateinstring  = [dateformatter stringfromdate:date]; 

when run following:

2016-08-07 @ 00:08:53, 2016-08-08 @ 15:29:21

however first date should following according epoch time converter website using:

your time zone: 8/7/2016, 12:08:53 gmt+1:00 dst

it says 00 rather 12. why that?

try set timezone of nsdateformatter gmt

[dateformatter settimezone:[nstimezone timezonewithabbreviation:@"gmt"]]; 

as larme , vadian suggested if want 12 hour use format

[dateformatter setdateformat:@"yyyy-mm-dd 'at' hh:mm:ss a"]; 

Comments

  1. @admin

    Our dental team is committed to excellent oral health for our patients. We offer comprehensive dental care and brilliant cosmetic dentistry to EAST HARTFORD and the surrounding areas.

    Regards,
    Dentist In East Hartford, CT

    ReplyDelete

Post a Comment

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -