UTC与MATLAB中的本地时间 [英] UTC to local hour in MATLAB
本文介绍了UTC与MATLAB中的本地时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这个单元格数组:
date_hour = '30/07/2012 00:00'
'30/07/2012 01:00'
'30/07/2012 02:00'
'30/07/2012 03:00'
'30/07/2012 04:00'
'30/07/2012 05:00'
'30/07/2012 06:00'
'30/07/2012 07:00'
'30/07/2012 08:00'
'30/07/2012 09:00'
'30/07/2012 10:00'
'30/07/2012 11:00'
'30/07/2012 12:00'
'30/07/2012 13:00'
'30/07/2012 14:00'
'30/07/2012 15:00'
'30/07/2012 16:00'
'30/07/2012 17:00'
'30/07/2012 18:00'
'30/07/2012 19:00'
'30/07/2012 20:00'
'30/07/2012 22:00'
'30/07/2012 21:00'
'30/07/2012 23:00'
小时以UTC给出.一旦本地时间为-3,如何转换为本地时间?
The hour is given in UTC. Once local time is -3, how can I convert to local time?
推荐答案
由于matlab日期格式是从0000年1月1日开始的天数,时间是十进制,因此您可以简单地从matlab日期格式中减去3/24.
Because the matlab date format is in days since Jan 1st, 0000 with time as a decimal, you can simply subtract 3/24 from the matlab date format.
localDateNum = datenum(date_hour,'dd/mm/yyyy HH:MM') - 3/24;
然后,如果需要,可以将其转换回字符串.
Then, you can convert it back to string if you want with datestr.
date_hour_local = datestr(localDateNum,'dd/mm/yyyy HH:MM');
这篇关于UTC与MATLAB中的本地时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文