Skip to content

Instantly share code, notes, and snippets.

@cullen-tsering
Last active August 29, 2015 14:03
Show Gist options
  • Save cullen-tsering/3dd47f192dcc121fa118 to your computer and use it in GitHub Desktop.
Save cullen-tsering/3dd47f192dcc121fa118 to your computer and use it in GitHub Desktop.
@cullen-tsering
Copy link
Author

public static class DateTimeExtension
{
    public static string yyyyMMddHHmmss(this DateTime t)
    {
        return t.ToString("yyyyMMddHHmmss");
    }

    public static string ShortDate(this DateTime t)
    {
        return t.ToString("d");
    }

    public static string HH_mm(this DateTime t)
    {
        return t.ToString("HH:mm");
    }

    public static string HH_mm_ss(this DateTime t)
    {
        return t.ToString("HH:mm:ss");
    }

    public static string HHmmss(this DateTime t)
    {
        return t.ToString("HHmmss");
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment