增加时间转换为yyyyMMddHHmmss格式扩展方法
This commit is contained in:
parent
0d7cbbe70c
commit
346ebc47c3
|
@ -90,6 +90,8 @@ namespace Falcon.SugarApi.Test
|
||||||
var d = new DateTime(2022, 1, 4, 2, 40, 25);
|
var d = new DateTime(2022, 1, 4, 2, 40, 25);
|
||||||
var s = d.ToyyyyMMdd();
|
var s = d.ToyyyyMMdd();
|
||||||
Assert.IsTrue(s == "20220104");
|
Assert.IsTrue(s == "20220104");
|
||||||
|
s = d.ToyyyyMMddHHmmss();
|
||||||
|
Assert.IsTrue(s == "20220104024025");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,6 +90,13 @@ namespace Falcon.SugarApi
|
||||||
/// <returns>yyyyMMdd格式时间</returns>
|
/// <returns>yyyyMMdd格式时间</returns>
|
||||||
public static string ToyyyyMMdd(this DateTime date) => date.ToString("yyyyMMdd");
|
public static string ToyyyyMMdd(this DateTime date) => date.ToString("yyyyMMdd");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取时间的yyyyMMddHHmmss表示形式
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="date">时间</param>
|
||||||
|
/// <returns>yyyyMMdd格式时间</returns>
|
||||||
|
public static string ToyyyyMMddHHmmss(this DateTime date) => date.ToString("yyyyMMddHHmmss");
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user