Skip to main content

DateTime

ToTimestamp(DateTime转时间戳)

DateTime.Now.ToUniversalTime();

ToDateTime(时间戳转DateTime)

now.ToTimestamp().ToDateTime();
caution

有精度问题,暂时没有很好的解决方案

DefaultString

DateTime date = new(2021, 11, 11, 11, 11, 11);
date.ToDefaultDateString(); // 2021-11-11
date.ToDefaultTimeString(); // 2021-11-11 11:11:11
date.ToDefaultDateString("WTF"); // 2021WTF11WTF11
date.ToDefaultTimeString("WTF"); // 2021WTF11WTF11 11:11:11
info

后面可能会尝试添加更多的格式