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