首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将RFC 3339日期时间转换为IST?

问如何将RFC 3339日期时间转换为IST?
EN

Stack Overflow用户
提问于 2019-06-17 10:24:23
回答 2查看 9.3K关注 0票数 1

我正在使用Google drive rest APIs列出我的Google drive文件。我正在我的驱动器中获取文件的以下元数据。这样,我就得到了RFC3339格式的“创建时间”。你能帮我把Google drive rest API返回的时间转换成IST吗?在Linux平台上有什么方法可以做到这一点吗?

代码语言:javascript
复制
{
 "files": [
  {
   "id": "1y_GB6OCBENf_gDMAzAHdN",
   "name": "testfile.jpg",
   "webViewLink": "https://drive.google.com/file/d/1y_GB6OCBENf_gDMAzAHdN/view?usp=drivesdk",
   "createdTime": "2019-06-17T02:08:50.959Z"
   }
  ]
}

注意:我使用curl工具从我的Linux服务器访问Google drive rest API。

EN

回答 2

Stack Overflow用户

发布于 2019-06-17 18:38:27

我知道您想要获取文件的创建日期,将其转换为IST并在您的代码中使用它,但如果我错了,请纠正我。你可以这样做:

代码语言:javascript
复制
#!/bin/bash

your_date="2019-06-17T02:08:50.959Z"

#Remove the Z from the date
formatZ="${your_date//Z}"

#Replace the T with a space
formatT=$(echo $formatZ | tr T " ") 

#Use the command date to convert the date we formatted
newdate=$(TZ=IST date -d "$formatT UTC-5:30")

echo $newdate
票数 1
EN

Stack Overflow用户

发布于 2019-06-17 18:41:38

您可以对parsing the ISO 8601/RFC 3339 timestamp使用date命令,然后对converting it to another timezone再次使用date命令。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56624057

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档