hello all,
I’m all new to this squirrel programming and didn’t find the right examples. I want the impserver to return a timestamp, formatted as a string to the imp.
I found this;
d = date(); datestring = format("%02d:%02d:%02d", d.hour, d.min, d.sec);
but I don’t know how to implement it. I like to add the date as well, like 20121231-23:59:31
I don’t understand:
"%02d:%02d:%02d"
sorry for this post. I found it
local d = date(); local datestring = format("%04d%02d%02d-%02d:%02d:%02d", d.year, d.month+1, d.day, d.hour, d.min, d.sec);
It saves me some RTC-hardware!!
I’m still looking for a list of all those formatcodes, but don’t know where to look…
DolfTraanberg, AFAIK, those format codes are identical to those of printf() from the C programming language.
So %04d means to display the number as decimal with four ciphers and leading zeros. %02d is the same, but only two ciphers.
Take a look here for more info (first hit on google): http://personal.ee.surrey.ac.uk/Personal/R.Bowden/C/printf.html
Thank you so much, it is very helpful