UNIX Timestamp in Coldfusion becomes 15 digits
1st set and call: 1666807130469
2nd set and call: 166680713046918XYZKEY999YYY5000{"symbol":"ETHUSDT","orderQty":0.03,"side":"Sell","orderType":"MARKET"}
Changes it to 15. I think I need it restricted to 13. Easiest way. Probably something simple? Why would it change it?
<cfset unixdatetimeNow = dateConvert( "local2Utc", now() )>
#unixdatetimeNow.getTime()#
<cfset encode = '#unixdatetimeNow.getTime()#XYZKEY999YYY{"symbol":"ETHUSDT","orderQty":0.03,"side":"Sell","orderType":"MARKET"}'>
Related
I'm looking for a way to set an arbitrary date, and every time I press a key it will print the day after it (tomorrow).
global jDate = "June 1, 1986"
^+z::
;Output our date in LongDate format
FormatTime, TimeString, %jDate%, LongDate
SendInput, %TimeString%
;Increment the date by a single day
jDate += 1, Days
Return
Unfortunately, it the code keeps starting jDate as today's current date/time rather than the past date I specify in the initial variable assignment. Not sure why. The incrementing works fine, it just increments starting from todays date rather that the 1986 date.
FormatTime is expecting any date/time input to be in the "YYYYMMDD..." format. Since what you've assigned to jDate doesn't fit that criterion, it assumes it's invalid and uses today's date. To make it work how you expect, just modify your jDate input.
jDate := "19860601" ; 1986 -> YYYY, 06 -> MM, 01 ->DD
A couple of things to note: (1) global is not needed in this context; (2) I would recommend getting out of the habit of assigning variables using the = comparator (use := assignment operator instead). It only works for legacy reasons but generates more confusion than it's worth. In the context that you're using it, the quotes would need to be removed.
I need to get the act hour in Lua without the leading zeros(in 24 hour mode)
it's like date("G") in PHP
I actually have this code
os.date("%d-%m-%Y %H")
but it returns me 01 , 02 , 03 .... and I need to get 1 , 2, 3 etc
I found this but it doesn't seem to help me to solve my problem
os.date formats
You can just remove the leading zero:
os.date("%d-%m-%Y %H"):gsub(" 0"," ")
Try to get hour :
local hour = os.date("%H")
And try to format with string.format :
string.format("%d", hour)
I wanted to calculate the seconds since the Unix Epoch (1970-01-01 00:00:00). Usually I would use
date +"%s"
Now, on my system the +"%s" option is not available but I easily got around using some other 'date' options and parsed it using bc:
date -u +"scale=0;(((((%Y-1970)*365.2425+%j)*24+%H)*60+%M)*60+%S)/1" | bc
This is short for
years = year_now - 1970
days = years * 365.2425 + day_of_year_now
hours = days * 24 + hour_now
minutes = hours * 60 + minute_now
seconds = minutes * 60 + second_now
So far so good. Then I discovered that the result of this calculation does not match with the result of the +"%s" option. I needed to add a magic number:
date -u +"scale=0;(((((%Y-1970)*365.2425+%j)*24+%H)*60+%M)*60+%S-36936)/1" | bc
Why?
Additionally, several months later, this magic number has changed from -36936 to -99792.
Why?
I'm sure something is wrong with my maths. I do not need better solutions in other script languages but I'd appreciate if somebody could correct my maths, please. Maybe someone has the source code for date and could show me its internal algorithm for +"%s" ... ?
Here is a POSIX way that should then work on all Unix and Unix like systems:
awk 'BEGIN {srand();print srand()}'
If you use ksh93, this should also work:
printf "%(%s)T\n"
Most system will have perl installed:
perl -le 'print time'
I need to create a list of days between a date interval.
Say for example from 2001-01-01 to 2009-12-31:
2001-01-01
2001-01-02
2001-01-03
..
2009-12-29
2009-12-30
2009-12-31
I know how to do it but maybe someone has a script already made?
If not, I will make such a script and upload it so others won't waste time on this when they need it.
I do not know awk from GnuWin32, but if the functions "mktime" and "strftime" are available, you can try the following code:
BEGIN {
START_DATE="2001-02-01"
END_DATE="2001-03-05"
S2=START_DATE
gsub("-"," ",S2)
T=mktime(S2 " 01 00 00")
if (T<0)
printf("%s is invalid.\n",START_DATE) >> "/dev/stderr"
else
{
for(S=START_DATE; END_DATE>S ;T+=86440) print S=strftime("%F",T)
}
}
The key is to convert the start date to a number meaning the seconds since the Epoch, add 86400 seconds (one day or 24 x 60 x 60) and convert back to the ISO date format.
After some trials I realized the mktime() function admits wrong dates as good (for instance, 2000-14-03).
Best regards
I am working within a batch file and need to pad a single digit with a leading 0 if under 10. I have the values in environmental variables. They are month and day, I need to pad to match file structure I am working against. I am using vbscript to return a date that comes back in the following format "7/16/2009". Need it to look like "07/16/2009" and most inportantly need each item in separate EVs.
VBscript:
WScript.Echo DateAdd("d", Date, -36)
Batch:
for /F "tokens=1-3 delims=/" %%x in ('cscript //nologo get36thday.vbs') do (
SET YYYY=%%z
SET MM=%%x
SET DD=%%y)
VBScript:
dteOldDate = Now()
strNewDate = Right("00" & Month(dteOldDate), 2) & "/" & Right("00" & Day(dteOldDate), 2) & "/" & Year(dteOldDate)
For the batch script, I don't know the exact syntax but a batch script can return a specified number of characters from the right side of a string.
So, append the month after a "0" character and take the 2 right-most digits. It would probably look something similar to this:
SET MM=0%%x
SET MM=%MM:~-2%
1 become 01
5 becomes 05
10 stays 10
Here is my method of padding strings.
In this example, MYVAR will be padded to five zeroes.
SET MYVAR=00000%MYVAR%
SET MYVAR=%MYVAR:~-5%
Athough the other answers are useful if you don't know the length of the string you want to pad with zeros up front, for dates and times a simple string replacement will do.
set hour=!TIME:~0,2!
set hour=!hour: =0!
In short, if there is a space it will be replaced by a 0.