Hey all!
I am reading the time and date of an email using “mail.headers” function & storing the info as a string in variable “strDate”, it is in US format.
strDate = 06/15/2020 14:45:43
(US format - MM/dd/yyyy hh:mm:as)
My question is, how do I convert strDate into UK format like this: 15/06/2020 (dd/MM/yyyy)
Thanks!
ppr
(Peter)
June 15, 2020, 4:25pm
2
@Suzana_Joby
ensure following:
Format Change:
DateTime.ParseExact(strDate, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture).toString("dd/MM/yyyy")
1 Like
Thanks for the quick reply!
This throws an error saying:
“String was not recognized as a valid Date time”
ppr
(Peter)
June 15, 2020, 4:35pm
4
@Suzana_Joby
have a look here for validation:
ensure your strDate is valid
2 Likes
msan
(Michel SAN)
June 15, 2020, 11:37pm
5
ppr’s code is correct but the forum “beautifies” the "
character to either “
or ”
. Use Preformatted Text to prevent that. The code in the quote and the line below can be copy/pasted.
DateTime.ParseExact(strDate, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture).toString("dd/MM/yyyy")
3 Likes
This works now! I forgot to put hours as HH (I put as hh before)
Thank you!
1 Like
system
(system)
Closed
June 19, 2020, 10:18am
7
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.