MacResource
how to set environment variable to current date, epoch format? - Printable Version

+- MacResource (https://forums.macresource.com)
+-- Forum: My Category (https://forums.macresource.com/forumdisplay.php?fid=1)
+--- Forum: Tips and Deals (https://forums.macresource.com/forumdisplay.php?fid=3)
+--- Thread: how to set environment variable to current date, epoch format? (/showthread.php?tid=86448)



how to set environment variable to current date, epoch format? - mattkime - 10-22-2009

i'm writing a script which will be triggered each time a file is dropped into a folder. I'd like the script to set an environment variable to the current date/time in epoch format.

export timeElapsed=123456767

will save the var

date +%s

will provide a time value in integer format.

how to combine the two lines?


Re: how to set environment variable to current date, epoch format? - Seacrest - 10-22-2009

surround the date command in ``, I think.


Re: how to set environment variable to current date, epoch format? - Seacrest - 10-22-2009

export myTime=`date +%s`;
echo $myTime;