# Get Events from Google Calendar with "minTime" and "maxTime"

**URL:** <https://discourse.nodered.org/t/get-events-from-google-calendar-with-mintime-and-maxtime/24771>\
**Category:** General\
**Created:** [13 April 2020 17:03 UTC](https://discourse.nodered.org/t/get-events-from-google-calendar-with-mintime-and-maxtime/24771 "2020-04-13T17:03:51Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![lstebe](https://avatars.discourse-cdn.com/v4/letter/l/b9e5f3/32.png) [@lstebe](https://discourse.nodered.org/u/lstebe)\
**Post date:** [14 April 2020 08:20 UTC](https://discourse.nodered.org/t/get-events-from-google-calendar-with-mintime-and-maxtime/24771/7 "2020-04-14T08:20:31Z")

</div>

thank you again, colin. there seemed to be a mistake of mine that i overlooked.  
the solution is the following:

storing the ISO strings as before in my systime function,  
comments for potential future Datefunction victims.

```auto
time = new Date(); // new date object

hour = time.getHours(); // extract the stuff
minute = time.getMinutes();
day = time.getDay();
date = time.getDate();
month = time.getMonth()+1; // necessary because months are indexed 0-11
year = time.getFullYear();

nowIso = time.toISOString(); // convert now to ISO string
inaweekstamp = Date.now()+604800000; // for inaweek timestamp + 7days in millisecs 
inaweek = new Date(inaweekstamp).toISOString(); // new dateobject from that and convert to ISO

var showhour;
var showminute;

if(minute < 10){
    showminute = "0"+minute;
}else{showminute = minute}
if(hour < 10){
    showhour = "0"+hour;
}else{showhour = hour}

global.set("systime",{"hour":hour,"minute":minute, "day":day, "date":date, "month": month, "year":year,"showhour":showhour, "showminute":showminute, "nowIso":nowIso,inaweek:inaweek});
node.status({text:"System Time: "+showhour+":"+showminute})

```

where now is safe, that nowISO and inaweek are ISO strings without a doubt

recall the variables anywhere else

```auto
systime = global.get("systime");
now = systime.nowIso;
inaweek = systime.inaweek;

msg.time = {now: now, inaweek:inaweek};
msg.payload = {calendarId:"stebe41@googlemail.com", maxResults: "20"};
msg.payload.timeMin = now;
msg.payload.timeMax = inaweek;
return msg;

```

---

_[View the full topic](https://discourse.nodered.org/t/get-events-from-google-calendar-with-mintime-and-maxtime/24771)._
