> Anyone written a script to convert unix timestamps (is 950618412) to
> a usable rebol date and time format. 
> 
> Cheers
> 
> Francois
> 
> 

Hi Francois:

Try this.


REBOL [
        Title: "Convert Epoch Time to Date"
        Author: "Ralph Roberts"
        File: %epoch-to-date.r
        Date: 21-Feb-2000
        Purpose: {converts UNIX Epoch time (seconds after 1-1-1970
                        to current date and time }
        Example: {outputs "Epoch date 951142987 is 21-Feb-2000
                14:38:52 GMT or 9:38:52 Local" }
        ]

        epoch: 951142987

        days: divide epoch 86400

        days2: make integer! days

        time: (days - days2) * 24
        hours: make integer! time
        minutes: (time - hours) * 100
        minutes2: make integer! minutes
        seconds: make integer! (minutes - minutes2) * 100
        time2: make time! ((((hours * 60) + minutes2) * 60) + seconds)

prin ["Epoch date" epoch "is" 1-Jan-1970 + days2 time2]
print [" GMT or" time2 + now/zone "Local"]

Reply via email to