Convert Date format into system date format

Hello Everyone,

I want to convert current date and time into system date format (It may change).
For an example Now is returning me date and time in 07/03/2020 (MM/dd/yyyy)15:00:02 and my system date format is 03/07/2020(dd/MM/yyyy) 15:00:02 (It can be 7/3/2020(M/d/yyyy) 03-07-2020(dd-MM-yyyy)).
I tried with getting the current culture method but it is always returning 07/03/2020 (MM/dd/yyyy - Invariant culture)

Thanks in advance :grinning:

@Arpit_Kesharwani

May I know in what format do you want ?

@lakshman I just want current date format in system format

@Arpit_Kesharwani

Try this:

             Now.ToString("dd/MM/yyyy HH:mm:ss)

@lakshman As I have mentioned in the thread System date can be in different format as well (It can be 7/3/2020(M/d/yyyy) 03-07-2020(dd-MM-yyyy)).

@Arpit_Kesharwani

After converting Date format into System date format then what you want to do it ?

@lakshman I need to pass that to the application which accepts system date format only

HI @Arpit_Kesharwani,

I believe this is what you are looking for.
It will get the regioninfo based on the settings on “Control Panel > Region > Home Location”

Regards,
Dimitris

Main.xaml (6.2 KB)

1 Like

Hi @dimibot, somehow you reached to the solution but code is calculating according to Geo Location(Nation/Country/region), It should be calculating as per the selected Regional format


English - Europe
image
English - US
image

1 Like

Indeed it was checking the Region set in Control Panel.
I think I found a better solution: In Registry Editor Under HKEY_CURRENT_USER/Control Panel/International
You have the date and time format of the machine.
For example if you want to get the ShortDate then you need an assign activity:
string shortDateFormat = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(“Control Panel\International”).GetValue(“sShortDate”)

Others values you can use there are: sShortTime, sTimeFormat, sLongDate etc.

3 Likes

@dimibot Wow, Thank you very much, it worked! :heart_eyes:
But I think there should be something from the Microsoft and UiPath, I have gone through many posts regarding the same problem in UiPath forum, StackOverflow, SuperUser etc. but they were just mentioning about the CultureInfo but that is not a solution of Regional Settings.

1 Like

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