Page 1 of 1

date,time format

Posted: Sun Sep 30, 2018 10:15 pm
by nemke
Hello to all
for project I need special sintax in http get request to server. I use fetch tool on MT but I need time and date from MT in special format understandable for server like this:
date,time example 300918,202130 (this is how remote server understand)
Where:
300918 = 30.sep.2018.
202130 = 20h 21min 30sec

How to achave this ? MT use NTP for clock

[admin@xxxxxxxx] > system clock print
time: 21:10:31
date: sep/30/2018
time-zone-autodetect: yes
time-zone-name: Europe/Belgrade
gmt-offset: +02:00
dst-active: yes

[admin@xxxxxxxxxx] /system ntp client> print
enabled: yes
primary-ntp: 10.20.20.254
secondary-ntp: 0.0.0.0
server-dns-names:
mode: unicast
poll-interval: 15m
active-server: 10.20.20.254
last-update-from: 10.20.20.254
last-update-before: 55s310ms
last-adjustment: 13ms692us

Re: date,time format

Posted: Fri Nov 16, 2018 2:09 pm
by astounding
You mean like this?
{
  :local mydatetime
  :local time [/system clock get time]
  :local date [/system clock get date]
  :local month [:tostr ([:find \
    "janfebmaraprmayjunjulaugsepoctnovdec" [:pick $date 0 3] \
  ]/3+1)]
  :if ([:tonum $month]<10) do={
    :set month "0$month"
  }
  :set mydatetime ( \
    $month.[:pick $date 4 6].[:pick $date 9 11].",". \
    [:pick $time 0 2].[:pick $time 3 5].[:pick $time 6 8] \
  )
  :put "Current date/time in DDMMYY,HHMMSS format is: $mydatetime"
}
-Astounding

Re: date,time format

Posted: Wed Dec 26, 2018 11:11 pm
by dhcpy
great code, thank you!!
You mean like this?
{
  :local mydatetime
  :local time [/system clock get time]
  :local date [/system clock get date]
  :local month [:tostr ([:find \
    "janfebmaraprmayjunjulaugsepoctnovdec" [:pick $date 0 3] \
  ]/3+1)]
  :if ([:tonum $month]<10) do={
    :set month "0$month"
  }
  :set mydatetime ( \
    $month.[:pick $date 4 6].[:pick $date 9 11].",". \
    [:pick $time 0 2].[:pick $time 3 5].[:pick $time 6 8] \
  )
  :put "Current date/time in DDMMYY,HHMMSS format is: $mydatetime"
}
-Astounding