How to convert specified time to GMT/UTC?
94 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
taimour sadiq
le 18 Oct 2023
Modifié(e) : Florian Bidaud
le 18 Oct 2023
i want to convert datetime({'18-Oct-2023 17:40:00' '18-Oct-2023 18:00:00'},'TimeZone','+05:00') to GMT or UTC?
required result below:
'18-Oct-2023 12:40:00' '18-Oct-2023 01:00:00'
0 commentaires
Réponse acceptée
Star Strider
le 18 Oct 2023
Modifié(e) : Star Strider
le 18 Oct 2023
Try this —
DT = datetime({'18-Oct-2023 17:40:00' '18-Oct-2023 18:00:00'},'TimeZone','+05:00')
DT_UTC = DT;
DT_UTC.TimeZone = 'UTC' % Copnmvert To UTC
DT_UTC.Format = 'dd-MMM-yyyy hh:mm:ss' % Convert To 12-Hour Time
EDIT — Added 12-Hour time conversion
.
0 commentaires
Plus de réponses (1)
Florian Bidaud
le 18 Oct 2023
Modifié(e) : Florian Bidaud
le 18 Oct 2023
https://uk.mathworks.com/help/matlab/ref/datetime.html#buhzxmk-1-TimeZone
date = datetime({'18-Oct-2023 17:40:00' '18-Oct-2023 18:00:00'},'TimeZone','+05:00')
datetime(date, 'TimeZone', 'UTC', 'Format', 'dd-MMMM-yyyy hh:mm:ss')
datetime(date, 'TimeZone', 'Europe/London', 'Format', 'dd-MMMM-yyyy hh:mm:ss')
0 commentaires
Voir également
Catégories
En savoir plus sur Dates and Time dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!