扩展DateTime类型的ToString

public static class ExtensionDateTime
{
public static string ToCustomString(this DateTime dt, bool isDefalut = false)
{
return isDefalut ? new DateTime(1900, 1, 1).ToString("yyyy-MM-dd HH:mm:ss") : dt.ToString("yyyy-MM-dd HH:mm:ss");
}

public static string DefaultTime()
{
return new DateTime().ToCustomString(true);
}
}

 

posted @ 2016-07-20 20:02  FH1004322  阅读(144)  评论(0编辑  收藏  举报