C# 中通用日期长时制 (“G”) 格式说明符
通用日期长时制的标准格式说明符是短日期 (“d”) 和长时制 (“T”) 的组合模式,由空格隔开。
设置日期 −
DateTime dt = new DateTime(2018, 1, 3, 3, 45, 20);
现在,使用 ToString() 方法和 DateTimeFormatInfo。
dt.ToString("G", DateTimeFormatInfo.InvariantInfo)示例
using System;
using System.Globalization;
class Demo {
static void Main() {
DateTime dt = new DateTime(2018, 1, 3, 3, 45, 20);
Console.WriteLine(dt.ToString("G",
DateTimeFormatInfo.InvariantInfo));
}
}输出
01/03/2018 03:45:20
广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP