Convert day of year to UTC format?
조회 수: 8 (최근 30일)
이전 댓글 표시
How would I go about converting this format to matlab UTC format?
ie:
2012-259T01:53:15.50194
2012-259T01:53:16.50194
댓글 수: 0
채택된 답변
Cris LaPierre
2023년 7월 14일
T = ["2012-259T01:53:15.50194";
"2012-259T01:53:16.50194"];
T = datetime(T,'InputFormat','uuuu-DDD''T''HH:mm:ss.SSSSS')
댓글 수: 12
Cris LaPierre
2023년 7월 17일
It is a best practice to always pair a hold on with a hold off. You can usually get things to look the way you want without it. The impact is usually later when you rerun your script, or if you create new plots by plotting in the same figure window. It's best to get in the habit while you are learning.
추가 답변 (1개)
Rahul
2023년 7월 14일
편집: Rahul
2023년 7월 14일
Hey Brandon,
The date time format provided by you, seemed to in the ISO 8601 format. Breaking down the format:
- '2012-259': date as year and day of the year. In this case, it indicates the 259th day of the year 2012.
- 'T': This is a separator indicating the start of the time component.
- '01:53:15': time in hours, minutes, and seconds. In this case, it indicates 1 hour, 53 minutes, and 15 seconds.
- '.50194': fractional part of the seconds. In this case, it indicates 50194 milliseconds.
You can use the following snippet to convert it to a standard UTC Timezone format:
inputTime = ['2012-259T01:53:15.50194'; '2012-259T01:53:16.50194'];
dt = datetime(inputTime, 'InputFormat', 'uuuu-DDD''T''HH:mm:ss.SSSSS', 'TimeZone', 'UTC')
You can refer to the datetime function documentation to further customize the code as per your needs.
Hope that Helped!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!