简体   繁体   English

在excel中格式化带时区的日期的代码

[英]Format code for a date with time zone in excel

I have date value with a time zone. 我有一个时区的日期值。

24 Nov 2005 GMT+05:30 2005年11月24日GMT + 05:30

What is the format code for this custom format in Excel? Excel中此自定义格式的格式代码是什么?

I tried dd MMM yyyy with z , zz , zzz , and Z but Excel ignores those options. 我用zzzzzzZ尝试了dd MMM yyyy ,但Excel忽略了这些选项。

Not sure if possible. 不确定是否可能。 I've just gone through every letter in custom format cell and nothing looked right. 我刚刚浏览了自定义格式单元格中的每一个字母,看起来没什么。

What I would suggest is maybe splitting it up into a few cells and then bringing them all together. 我建议的可能是将它分成几个单元格,然后将它们组合在一起。

In the first column (A1) you could have the date, formatted how you like (dd mmm yyyy). 在第一列(A1)中,您可以拥有日期,格式化您喜欢的格式(dd mmm yyyy)。

Second (B1) you could have the time before you account for the different timezone (formatted how you like, ie hh:mm:ss. 第二个(B1)你可以有时间考虑不同的时区(格式化你喜欢的方式,即hh:mm:ss。

Third (C1) define if the timezone is ahead or behind with a plus/minus sign. 第三个(C1)用加号/减号定义时区是前面还是后面。

Fourth (D1) you could set the time difference (ie your example +5:30). 第四(D1)你可以设置时差(即你的例子+5:30)。 Format the cell as h:mm. 将单元格格式化为h:mm。

Fifth (E1), enter the formula: =IF(C1="+",B1+D1,IF(C1="-",B1-D1)). 第五(E1),输入公式:= IF(C1 =“+”,B1 + D1,IF(C1 =“ - ”,B1-D1))。 Format the cell as hh:mm:ss. 将单元格格式化为hh:mm:ss。

Finally, (F1) there's two options for you. 最后,(F1)有两种选择。 You can combine the date and time adjusted to the timezone, or you can combine the date, original time and include timezone. 您可以将调整后的日期和时间组合到时区,也可以组合日期,原始时间和包含时区。

The first option would be: =TEXT(A1,"dd mmm yyyy ")&TEXT(E2,"hh:mm:ss") 第一个选项是:= TEXT(A1,“dd mmm yyyy”)和TEXT(E2,“hh:mm:ss”)

Second would be: =TEXT(A1,"dd mmm yyyy ")&TEXT(B1,"hh:mm:ss ")&"GMT"&TEXT(C1,"")&TEXT(D1,"h:mm") 第二个是:= TEXT(A1,“dd mmm yyyy”)和TEXT(B1,“hh:mm:ss”)和“GMT”&TEXT(C1,“”)和TEXT(D1,“h:mm”)

This is the absolute best solution I could think of. 这是我能想到的绝对最佳解决方案。 Sorry if it's not what you asked for. 对不起,如果这不是你要求的。

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

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