Old 22nd May 2019, 04:34   #1
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
Post 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.
meoit is offline   Reply With Quote
Old 22nd May 2019, 10:11   #2
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,103
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".

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 22nd May 2019, 10:34   #3
meoit
Member
 
Join Date: Oct 2014
Location: $DESKTOP
Posts: 90
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.
meoit is offline   Reply With Quote
Old 22nd May 2019, 10:38   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,103
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?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Old 22nd May 2019, 12:35   #5
ahmett
Junior Member
 
Join Date: Jan 2008
Posts: 18
Quote:
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...
ahmett is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump