我正在使用Google drive rest APIs列出我的Google drive文件。我正在我的驱动器中获取文件的以下元数据。这样,我就得到了RFC3339格式的“创建时间”。你能帮我把Google drive rest API返回的时间转换成IST吗?在Linux平台上有什么方法可以做到这一点吗?
{
"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。
发布于 2019-06-17 18:38:27
我知道您想要获取文件的创建日期,将其转换为IST并在您的代码中使用它,但如果我错了,请纠正我。你可以这样做:
#!/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发布于 2019-06-17 18:41:38
您可以对parsing the ISO 8601/RFC 3339 timestamp使用date命令,然后对converting it to another timezone再次使用date命令。
https://stackoverflow.com/questions/56624057
复制相似问题