0

I want a .NET C#\VB.NET code for followng problem I want to calculate the Date from seconds for example I have 1304393880 seconds and this represents 2011-05-06 and 0900 hrs . So these seconds keep updating on daily basis. so next day I will have 1304393880 + 24*60*60 =1304480280. now when I calculate 1304480280 sec to date at 9 A.M it should give me 2011-05-07-0900 Please help

skaffman
  • 398,947
  • 96
  • 818
  • 769
sandeep
  • 1
  • 1
  • do you want psuedo-code or are you working in a specific language – Grady Player May 09 '11 at 20:35
  • 1
    Do you know the difference between the Julian and the Gregorean calendar? – Toon Krijthe May 09 '11 at 20:35
  • sure, but tell us what language you doing it in? – Shaunak May 09 '11 at 20:36
  • sorry pal, but I have to ask why? – Bastardo May 09 '11 at 20:41
  • I want to download data from URL " http://www.google.com/finance/getprices?q=RELIANCE&x=NSE&i=60&p=5d&f=d,c,o,h,l&df=cpct&auto=1&ts=1266701290218 " so in data on 8th line I have something like this "a1304393880" a represents begining and rest string represent the date. So I want to get that date – sandeep May 09 '11 at 20:48
  • 1
    @sandeep Are you sure this is since the A.D 01-01-0001 cos I am really am not. – Bastardo May 09 '11 at 20:57
  • 1
    That looks like seconds since 1st Jan 1970 (Unix Time). Not A.D 01-01-0001. In which case this is a possible duplicate of [Parsing unix time in C#](http://stackoverflow.com/questions/1674215/parsing-unix-time-in-c) – Martin Smith May 09 '11 at 21:31

1 Answers1

1

Whatever language you're working in has some kind of Epoch (the date/time represented by 0 seconds). Simply calculate the #of seconds between that language-specific Epoch, and 01-01-0001, and add that constant to your calculations as appropriate.

Here's the calculation, from WolframAlpha:

http://www.wolframalpha.com/input/?i=seconds+since+0%3A00%2C+01-01-0001

jefflunt
  • 33,527
  • 7
  • 88
  • 126