Re: (PLEASE: DESPERATED) Conversion from seconds to YYYY-MM-DD : HH-MM-SS

From: Paul E. Black (p.black_at_acm.org)
Date: 11/14/03


Date: 14 Nov 2003 12:45:34 -0500

Olathe <Olathe@DALnet.irc> writes:

> >>Gustavo Rios writes:
> >>
> >>>... convert a given number of seconds_in_year since
> >>>01/01/1970 UTC to a given format: YYYY-MM-DD : HH-MM-SS.

Julian date routines do this quite well. A "Julian date" is the
number of seconds since a point in the far past (4,000 something
B.C.). So date calculations are just converting dates to "Julian
dates" (seconds), adding or subtracting seconds, then converting back
to YYYY-MM-DD.

For instance if you have the number of seconds since 01/01/1970 and
you want the year, month, and day, do something like this
   epoch = yyyymmddToJulian(01/01/1970);
   currentDate = JulianToyyyymmdd(epoch + numberOfSeconds);
where currentDate has the year, month, and day broken out. Remaining
seconds can be converted to hours, minutes, and seconds in a straight-
forward way.

I have some well-tested Julian date routines in C that I'd be happy to
send you.

-paul-

-- 
Paul E. Black
p.black@acm.org


Relevant Pages

  • Re: get date - 1 day
    ... because you have to write your own routines to ... Please note that VBScript cannot, unaided, determine true Julian Dates, ... which changes at midnight local time. ...
    (microsoft.public.scripting.vbscript)
  • Re: ANN: Julian dates
    ... those who use Tcl/SQLite, but hopefully not limited to those, I've ... relatively portable C library of Julian ... date routines, and a Tcl binding for it under an open source license. ... 73 de ke9tv/2, Kevin ...
    (comp.lang.tcl)
  • Re: get date - 1 day
    ... because you have to write your own routines to ... stepping Y M D back one day at a ... They involve formulae like these to calculate Julian dates: ... In my book this is a little more involved than writing ...
    (microsoft.public.scripting.vbscript)
  • Re: Converting Julian Dates to regular dates
    ... You sure they are Julian dates not just Excel's 5-digit serial numbers? ... See Chip Pearson's site for methods of converting. ... Gord Dibben MS Excel MVP ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Date Addition/Subtraction in CL
    ... Converting to Julian is how I subtract dates in CL. ... Prev by Date: ...
    (comp.sys.ibm.as400.misc)

Loading