Skip to content

Instantly share code, notes, and snippets.

@DorukUlucay
Created December 7, 2017 11:26
Show Gist options
  • Save DorukUlucay/5bd65dd2f543b02a0ca10ef81c354068 to your computer and use it in GitHub Desktop.
Save DorukUlucay/5bd65dd2f543b02a0ca10ef81c354068 to your computer and use it in GitHub Desktop.
some useful code snippets
using System;
namespace FormUI
{
public class Helper
{
private static string stampFormat = "{0}{1}{2}T{3}{4}{5}";
public static string TimeStamp()
{
var now = DateTime.Now;
var result = string.Format(stampFormat, now.Year, Pad("00", now.Month), Pad("00", now.Day), Pad("00", now.Hour), Pad("00", now.Minute), Pad("00", now.Second));
return result;
}
public static string Pad(string padding, int value)
{
return Pad(padding, value.ToString());
}
public static string Pad(string padding, string value)
{
string result = padding.Substring(0, padding.Length - value.Length) + value;
return result;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment