Skip to content
⌘ NSIS Forum Archive

NSIS how to get server/network/internet date-time

5 posts

meoit#

NSIS how to get server/network/internet date-time

Hi all.

I am need to get server/network/internet date-time (GMT+6).

https://www.timeanddate.com/worldclock/thailand

The NSIS is possiable for this ?.

Thanks.
Anders#
Do you actually need to get the time from some server on the internet or just the current time from the local system with some offset from UTC/GMT?

The answer for the former is that you would have to write a plug-in that speaks the NTP protocol or find a plain-text online service that gives you the time in a simple format.

Windows by default already synchronizes its clock with "internet date-time".
meoit#
Anders.

I need get date-time from web https://www.timeanddate.com/worldclock/thailand

Maybe, sychronize the current time from the local system is disabled.
Anders#
There is no standard to synchronize time over HTTP.

You could download that page with INetC and then parse it manually but that is ugly and error prone. What happens if they change their HTML layout?
ahmett#
nsJSON::Set /tree HttpWebRequest /value `{ "Url": "http://worldtimeapi.org/api/timezone/Etc/GMT+7", "Verb": "GET", "DataType": "JSON }`
nsJSON::Set /tree HttpWebResponse /http HttpWebRequest
nsJSON::Serialize /tree HttpWebResponse
Pop $0
nsJSON::Set /value $0

nsJSON::Get `Output` 'utc_datetime' /end
Pop $1
Detailprint $1
nsJSON::Get `Output` 'datetime' /end
Pop $1
Detailprint $1
Try nsJSON plugin...