0

i am having a timestamp from 1980 not 1970 (unix epoch time), now how to convert this timestamp to local time in c++, i have seen at convert timpstamp to date in c++ and convert custom epoch timestamp to date in java how to do that in c++

Time stamp sample = 1315665000

Original Date = 09-09-2021

srilakshmikanthanp
  • 2,008
  • 1
  • 6
  • 19
  • 1
    What format is your epoch in? Is there any sample code? This question is pretty bare bones right now. – Stephen Newell Jan 24 '22 at 16:06
  • Thanks for comment I have added the sample timestamp from 1980. I don't how to approch it whether it whould be fine adding 10 years to or not. Any sugessitions is mush appericiated – srilakshmikanthanp Jan 24 '22 at 16:11
  • Does adding 315532800 to your timestamp work? This should add the difference between 1970-01-01 and 1980-01-01. E.g. your sample converts to Tuesday August 10, 2021 10:21:41 (am) UTC – PeteP Jan 24 '22 at 16:13
  • @PeteP I have changed the timestamp and that works Fine :) but can i use this method this will work for all or there is any standars way to do this ? – srilakshmikanthanp Jan 24 '22 at 16:20
  • Please check this link: https://stackoverflow.com/questions/1692184/converting-epoch-time-to-real-date-time It seems useful in such case. – Md. Faisal Habib Jan 24 '22 at 16:22
  • @srilakshmikanthanp adding 315532800 to all your timestamps will work, it just adds the "missing" seconds between 1970-01-01 and 1980-01-01 to convert to a unix timestamp. Adding 10 years will miss the 2 leap years from the 70s so would be out by 2 days. – PeteP Jan 24 '22 at 16:36
  • Thanks :) for your sugessition – srilakshmikanthanp Jan 24 '22 at 16:47

0 Answers0