convert date and time in seconds
显示 更早的评论
Hello everyone, I have a table with several variables. Among others, I have 2 columns with date and time. These 2 columns are cells with strings ('iscellstr'=1 and 'ischar'=0). How can I convert them in seconds? thank you very much!
7 个评论
Walter Roberson
2018-9-4
You could calculate number of seconds since some event, such as by converting serial date numbers from days into seconds. This would, however, be prone to errors due to leap seconds and calendar changes that happened at different dates in different parts of the world.
Nivodi
2018-9-4
jonas
2018-9-4
But you will also get unique values if you convert the time stamps (date+time) to a datetime array. Unless there is a specific reason you need the data to be in seconds (or any other duration), then I'd strongly recommend simply converting your time-vector to a datetime array and work with that.
Nivodi
2018-9-4
编辑:Walter Roberson
2018-9-4
jonas
2018-9-4
Not sure what you are doing, but that is not the correct syntax. I wrote some lines of code in the answer section to give you an idea of what I meant.
Nivodi
2018-9-4
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!