You can use the clock function to achieve this:
set now [clock format [clock seconds] -format "%d/%m/%y %H:%M:%S" -timezone "America/New_York"]
puts "$now"
题
I have 2 date variables in a expect script. One of them returns the local date and i want the second date returns a date with a different GMT time zone in a expect script. My code:
set date_hour_date1 [timestamp -format %Y/%m/%d]
set date_hour_date2 [timestamp -format %Y/%m/%d -gmt "America/New_York"]
When i run my script returns this error:
args: [-seconds #] [-format format] [-gmt]
while executing
"timestamp -format %C%y%m%d -gmt "America/New_York""
invoked from within
"set tmp [timestamp -format %C%y%m%d -gmt "America/New_York"]"
My conclusion is that "America/New_York" is not a correct parameter. I have tried to look some examples around the internet but i can't find anything.
Is there any example to use gmt flag in a expect script?
解决方案
You can use the clock function to achieve this:
set now [clock format [clock seconds] -format "%d/%m/%y %H:%M:%S" -timezone "America/New_York"]
puts "$now"