'How can i remove all the forward slash "/", Colons ":" and spaces from DateTime.Now format

I want to convert DataTime.Now output into a interger,

I want to remove all the forward slash "/" Colons ":" and spaces " " even PM/AM.

example:

From = 1/24/2022 10:51:54 PM

to = 1242022105154



Solution 1:[1]

You can use as below:

From.ToString().Replace("/","").Replace(":","").Replace(" ","")

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1