Skip to content

Instantly share code, notes, and snippets.

@glennlopez
Created June 22, 2020 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save glennlopez/e17ca2504061d2c71aebbf527d8e35b4 to your computer and use it in GitHub Desktop.
Save glennlopez/e17ca2504061d2c71aebbf527d8e35b4 to your computer and use it in GitHub Desktop.
/// <summary>
/// Datestamp_demo
/// </summary>
/// <returns>formatted date as per user configuration</returns>
public static string formatedDate(string usrFormat)
{
StringBuilder simplifiedDateFormat = new StringBuilder("");
// simplify date formatting usrFormat
int index = 0;
foreach (char letter in usrFormat)
{
if (letter == 'm')
{
simplifiedDateFormat.Append(Char.ToUpper(letter));
index++;
}
else
{
simplifiedDateFormat.Append(letter);
index++;
}
}
return DateTime.UtcNow.ToString(simplifiedDateFormat.ToString());;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment