Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I'm reading time into a variable from a CSV file but some of the time like 9 am is written as 9:00 instead of 09:00. How can I correct it into HH: mm format?
This should do the trick:
('9:00' -as [datetime]).ToString('HH:mm')
You can see it working on a loop from 0:00 to 12:00 with this:
PS /~> 0..12|%{("$_`:00" -as [datetime]).ToString('HH:mm')} 00:00 01:00 02:00 03:00 04:00 05:00 06:00 07:00 08:00 09:00 10:00 11:00 12:00
Add a comment
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.