So I found this questions interesting and searched a little on StackOverflow on how to do this in Javascript in general and found the following plugin, that can send requests to web servers:
https://forums.rpgmakerweb.com/inde...x-request-data-from-a-web-server.48720/page-2
Here you have to take the code of the corrected version from the last post in the thread and save it in your games plugin folder as Ajax.js! Otherwise it won't work.
This plugin sends synchronous requests to the web server, so your game might be blocked when the web server is down or maybe of some other reasons.
Before answering, I've tried this out myself using the following plugin parameter:
This web service is time zone based and berlin was given as an example on their website. In their FAQ section they state, that their service should be used for non-commercial applications and as they sometimes go down for longer periods commercial application should only use it on their own risk. I guess for this case it would be better to find another web service for this particular use case or host your own.
In my test in order to try it out, I've set up the following event:
Spoiler: Event
The first set variable command uses the following script call:
new Date(JsonEx.parse(ajaxRequest("")).datetime).getTime()
The web service I've used in the test returns a Json-String with a lot of information, that I needed to parse first and then retrieve the datetime field from the JSON-Object and then convert it into a Date object from which I can access the different values via the get functions.
const date = new Date(JsonEx.parse(ajaxRequest("")).datetime);
$gameVariables.setValue(6, date.getFullYear());
$gameVariables.setValue(7, date.getMonth() + 1);
$gameVariables.setValue(8, date.getDate());
This script call sets 3 variables 6,7 and 8 to the Year, Month and Day of Month accordingly.
Also found another plugin in for this called MVHTTP on github, but I am unsure if I am allowed to link to it. It is a little bit more sophisticated as you can also do asynchronous requests to the web server, but I haven't tried it out. It is for MV, but everything except the plugin command to change the webserver address used should also work in MZ.
I hope this helps and I wonder a little bit what kind of event this should be, so that you need to be so overprotective?