Place to put your Basic demos and examples

Moderator: Mmiscool

User avatar
By psc-esp8266
#44870 For a logging purpose I needed the current date/time. The present time() function unfortunately displays the month as a 3 letter string. This makes it unusable for sorting. To solve this I created an ugly solution that does the job:

let maanden = "-01-:Jan-02-:Feb-03-:Mar-04-:Apr-05-:May-06-:Jun-07-:Jul-08-:Aug-09-:Sep-10-:Oct-11-:Nov-12-:Dec"
Let TimeNow = time(YEAR) & mid(maanden,instr(maanden,":" & time(MONTH))-4,4) & time(DATE) & "T" & time(TIME)

TimeNow contains the data now like: "2016-04-05T13:50:32" instead of "Tue Apr 05 13:50:32 2016".
and contains no spaces so perfect for use in web functions like wget.
User avatar
By psc-esp8266
#47030 Due to a small change in command interpreter the "DATE" parameter for the Time() function shoud now be "DAY".
To get a date in YY-MM-DDThh:mm format you must use:

Let maanden = "-01-:Jan-02-:Feb-03-:Mar-04-:Apr-05-:May-06-:Jun-07-:Jul-08-:Aug-09-:Sep-10-:Oct-11-:Nov-12-:Dec"
Let TimeNow = time(YEAR) & mid(maanden,instr(maanden,":" & time(MONTH))-4,4) & time(DATE) & "T" & time(TIME)

Note that if you change in string "maanden" all '-' into '/' you will get YY/MM/DDThh:mm.