简体   繁体   English

将UTC时间转换为太平洋时间的Excel公式

[英]Excel formula to convert UTC time to Pacific Time

A system I am using provides UTC time in the following format.我正在使用的系统以以下格式提供 UTC 时间。 20190802145655UT 20190802145655UT

What Excel formula could I use to convert this to a timestamp 8-2-19 7:56:55 AM?我可以使用什么 Excel 公式将其转换为时间戳 8-2-19 7:56:55 AM? I've done a bunch of searches, but the format the time is provided in is giving me a hard time.我已经进行了大量搜索,但是提供时间的格式让我很难受。 (PDT should have been -7 hours that day.) (那天 PDT 应该是 -7 小时。)

Thanks for any help in advance!提前感谢您的任何帮助!

=TEXT(LEFT(A1,14),"0000-00-00 00\:00\:00")-7/24

and format as "md-yy h:mm:ss AM/PM"并格式为“md-yy h:mm:ss AM/PM”

在此处输入图片说明

This formula will convert your UT string in cell A2 to a proper date/time value.此公式会将单元格 A2 中的 UT 字符串转换为正确的日期/时间值。

=VALUE(MID(A2,19,18))

This could be made more complicated by searching for the opening parenthesis but I believe your format is very rigid, with the parenthesis always in 18th position.通过搜索左括号可以使这变得更加复杂,但我相信您的格式非常严格,括号总是在第 18 位。 Therefore it can be hard-coded.因此它可以被硬编码。

The formula will return a number.该公式将返回一个数字。 Format the cell with a custom format like mm/dd/yyyy hh:mm:ss or any other format you prefer.使用自定义格式(例如mm/dd/yyyy hh:mm:ss或您喜欢的任何其他格式)格式化单元格。

You can adjust the number as follows.您可以按如下方式调整数字。

=VALUE(MID(A2,19,18))+(-7/24)

In this example 7 hours are being deducted from the given time.在此示例中,从给定时间中减去 7 小时。 If you need more flexibility you can replace the -7 with a cell reference.如果您需要更大的灵活性,您可以用单元格引用替换-7

I tried the formulas provided and neither worked for me.我尝试了提供的公式,但都不适合我。

I used this and it seems to work... =C7-7/24我用过这个,它似乎有效... =C7-7/24
C7 is first cell with UTC to convert C7 是第一个要转换的 UTC 单元格

I used the following format, custom mm/dd/yyyy h:mm AM/PM我使用了以下格式,自定义 mm/dd/yyyy h:mm AM/PM

utc converted to PST time UTC 转换为 PST 时间

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM