Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9221255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:32:19+00:00 2026-06-18T03:32:19+00:00

with apps script and google calendar I get the events with same name :

  • 0

with apps script and google calendar I get the events with same name:

function authorize() {
  var oauthConfig = UrlFetchApp.addOAuthService("calendar");
  var scope = "https://www.googleapis.com/auth/calendar";
  oauthConfig.setConsumerKey("anonymous");
  oauthConfig.setConsumerSecret("anonymous");
  oauthConfig.setRequestTokenUrl("https://www.google.com/accounts/OAuthGetRequestToken?scope="+scope);
  oauthConfig.setAuthorizationUrl("https://accounts.google.com/OAuthAuthorizeToken");    
  oauthConfig.setAccessTokenUrl("https://www.google.com/accounts/OAuthGetAccessToken");  
}

function beginEnd(calId, eventName){
  authorize();
  var key = "...";
  var query = encodeURIComponent(eventName); 
  calId = encodeURIComponent(calId);
  var params = {
    method: "get",
    oAuthServiceName: "calendar",
    oAuthUseToken: "always",
  };
  var url = "https://www.googleapis.com/calendar/v3/calendars/"+
    calId+"/events?q=" + query + "&key=" + key;
  var request = UrlFetchApp.fetch(url, params);
  var response = Utilities.jsonParse(request.getContentText());
  var items = response.items;
  for ( i = 0 ; i < items.length ; i++){
    var start = (items[i].start.dateTime);
    var end =  (items[i].end.dateTime);
    Logger.log( [start,end]);
  } 
}

but, when I try convert start to new Date:

var start = (items[i].start.dateTime);
Logger.log(start);
Logger.log( new Date(start) );

I get

2013-01-21T15:00:00-03:00
Wed Dec 31 16:00:00 PST 1969

why ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T03:32:20+00:00Added an answer on June 18, 2026 at 3:32 am

    Seems that date definition doesn’t like hyphens…

    it works like this, even if I’m sure a better solution can be found (I’m not a regex expert 😉

    Logger.log(new Date('2013-01-21T15:00:00-03:00'.replace(/-/g,'/').replace(/[A-Z]/,' ').substr(0,19)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using UrlFetchApp in a google apps script to perform a get, as
I'am very new to google-apps-script. I encounter this error TypeError: Cannot find function getValue
I'm using a general Google Apps Script function to be able to read, prettify
Using Google Apps Script, I created a calendar that has a complex recurring event.
When using the following code in Google Apps Script, the function runs properly, but
I have a service that creates a jSon response in Google Apps Script function
In a Google Apps Script, I have the following script: function doGet() { return
I'm fairly experienced with Google Apps Script in Spreadsheets, and want to get going
SETUP: Using Google Apps Script's UI (doGet) with tabPanel option. At the bottom of
Using Google Apps Script, I've made a UI for use on a Google Spreadsheet.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.