简体   繁体   English

谷歌日历事件的JS日期格式

[英]Js date format from google calendar event

I got event from google calendar and event has end time if format 2018-07-19T00:00:00+03:00 . 我从Google日历获取事件,并且事件的结束时间为格式2018-07-19T00:00:00 + 03:00 How can I get normal date from this? 我如何从中得到正常日期? Year, month, day, hour, minutes? 年,月,日,小时,分钟? Thanks. 谢谢。

you just need to use the Date object of JavaScript : 您只需要使用JavaScript的Date对象:

let date = new Date('2018-07-19T00:00:00+03:00');

Here's the link to documentation : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date 这是文档的链接: https : //developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date

This object as many method to get part of the date or to get representation of it. 此对象是获取部分日期或获取日期表示的许多方法。 As the documentation show in the example you can event do basic math beetween Dates 如示例中的文档所示,您可以在日期之间进行基本的数学运算

You can use moment or date-fns they are librairies to format dates. 您可以使用momentdate-fns形式的fns来格式化日期。

Example: 例:

import moment from 'moment';
const day = moment('2018-07-19T00:00:00+03:00').format('DD');

if you are not using ES6/ES7, you can add the cdn to your project and use it the same way. 如果不使用ES6 / ES7,则可以将CDN添加到项目中,并以相同的方式使用它。

If you don't like using librairies, you can do it using js Date . 如果您不喜欢使用库,则可以使用js Date

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google使用日期格式表示日历事件问题 - Google forms to calendar event issues with date format 如何从公共谷歌日历中仅获取某些事件并将事件日期插入 js 倒计时 - How to get only certain events from a public google calendar and insert the event date in a js countdown Google 日历 - 事件日期,而不是第一次实例日期 - Google Calendar - Event Date, not first instance date 为什么此Google日历活动格式无效? - Why is this Google Calendar Event format invalid? 谷歌日历日期字符串到 JS 日期 Object - Google Calendar Date String to JS Date Object 在节点js中获取Google日历事件ID - Get google calendar event ID in node js 从导入日期来自电子表格创建Google日历事件时出现setHours()错误 - Apps脚本 - setHours() Error when Creating a Google Calendar Event from Imported Date Coming From Spreadsheet - Apps Script 当我从谷歌表格中的开始日期和结束日期创建事件时,日历中的结束日期比前一天 - When I create an event from a start date and end date in a google sheet, the end date in the calendar is one day earlier 使用html5时间和日期输入的Google Apps脚本创建日历事件? - Creating a calendar event with Google Apps Script from html5 time and date inputs? 通过超链接创建Google日历活动 - Creating a Google Calendar Event from hyperlink
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM