Unix time conversion

#1
Are there any functions or scripts to convert the current date/time or a user-specified date/time to UNIX epoch seconds (seconds since 1970-01-01 00:00:00 UTC) ?

I see that %@makeage[] and %@agedate[] are good contenders, but I want the UNIX time stamp system, not the NTFS time stamp system. TIA for any help.

This is not urgent. In the interim, I have written a batch file that uses date.exe from the core-utils package at GnuWin32.sourceforge.net. I just wanted to know if I could have done the same thing with TCC functions.
 
#2
On Tue, 18 Nov 2008 20:48:18 -0600, Eric Pement <> wrote:


>Are there any functions or scripts to convert the current date/time or a user-specified date/time to UNIX epoch seconds (seconds since 1970-01-01 00:00:00 UTC) ?
You could easily build your own.

function utime `%@eval[%@makeage[%_date %_time] \ 10000000 - 11644473600]`

echo %@utime[]
1227048797

I could put a _UTIME variable in my 4UTILS plugin.
 
#3
You could wrap your own function to use the age functions and subtract and
divide. I don't have handy TCC references with me just now, but look up the
user functions.

On Tue, Nov 18, 2008 at 6:48 PM, JP Software Forums <[email protected]> wrote:


> Are there any functions or scripts to convert the current date/time or a
> user-specified date/time to UNIX epoch seconds (seconds since 1970-01-01
> 00:00:00 UTC) ?
>
> I see that %@makeage[] and %@agedate[] are good contenders, but I want the
> UNIX time stamp system, not the NTFS time stamp system. TIA for any help.
>
> This is not urgent. In the interim, I have written a batch file that uses
> *date.exe *from the core-utils package at GnuWin32.sourceforge.net. I just
> wanted to know if I could have done the same thing with TCC functions.
>
>
>
>
>


--
Jim Cook
2008 Fridays: 4/4, 6/6, 8/8, 10/10, 12/12 and 5/9, 9/5, 7/11, 11/7.
Next year they're Saturday.
 
#4
On Tue, 18 Nov 2008 20:48:18 -0600, Eric Pement <> wrote:




You could easily build your own.

function utime `%@eval[%@makeage[%_date %_time] \ 10000000 - 11644473600]`

echo %@utime[]
1227048797

I could put a _UTIME variable in my 4UTILS plugin.
Better change that to:

function utime `%@eval[%@makeage[%_utc] \ 10000000 - 11644473600]`
 
May 29, 2008
533
3
Groton, CT
#6
Are there any functions or scripts to convert the current date/time or a user-specified date/time to UNIX epoch seconds (seconds since 1970-01-01 00:00:00 UTC) ?

I see that %@makeage[] and %@agedate[] are good contenders, but I want the UNIX time stamp system, not the NTFS time stamp system. TIA for any help.

This is not urgent. In the interim, I have written a batch file that uses date.exe from the core-utils package at GnuWin32.sourceforge.net. I just wanted to know if I could have done the same thing with TCC functions.
I use these functions, but they're not adjusted for UTC:


function unixtodate=`%@agedate[%@eval[%@if[%@eval[%1 - 0x80000000] lt 0,%1,(%1 - 0x100000000)]*10000000 + %@makeage[1970-1-1]]]`

function datetounix=`%@eval[(86400 * (3652 + %@date[0%1])) + %@time[0%2]]`


You can adjust for your offset from UTC by adding (%_tzo * 60) to the local time in the datetounix function.
 
#8
On Thu, 20 Nov 2008 13:39:10 -0600, Eric Pement <> wrote:


>---Quote (Originally by vefatica)---
>Oops! I should have said:
>
>function utime `%@eval[%@makeage[%_utcdate %_utctime] \ 10000000 - 11644473600]`
>---End Quote---
>Just want to say thanks to you and the others who provided such a speedy reply. I appreciate it!
It can be made into a variable as well (instead of a variable function).

set _UTIME=`%@eval[%@makeage[%_utcdate %_utctime] \ 10000000 - 11644473600]`

echo %_utime
1227210439