Get today date

I want to get today date format as 3-Jan-2020. How can I do that?

Also I have a date string as 3/1/2020 15:16:00, I want to change it to
3-Jan-2020 15:16. How can I do that?

2 Likes

Hi @Emily_Yip

Now.ToString("d-MMM-yyyy hh:mm)

Thanks
Ashwin S

2 Likes

you can use DateTime var type
and if you have 3/1/2020 15:16:00
you can use this syntax Datetime.parseexact(“3/1/2020”,“dd/MM/yyyy”,system.globalization.cultureinfo.invariantculture).to string(“dd-MMM-yyyy”)

3 Likes

Hi @Emily_Yip,

To get today’s date in the expected format

Now.ToString(“d-MMM-yyyy”)

Gives the current date in the following format → 3-Jan-2019

To Convert the date from one format to the expected format will be like

DateTime.Parse(DateVariable).ToString(“d-MMM-yyyy hh:mm”)

Converts the date variable in the following format → 3-Jan-2020 15:16

6 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.