C# datetime 输出格式
https://docs.microsoft.com/zh-cn/dotnet/api/system.datetime.tostring?view=netframework-4.8#System_DateTime_ToString_System_IFormatProvider_
https://www.cnblogs.com/polk6/p/5465088.html
using System;
using System.Globalization;
public class Example
{
public static void Main()
{
// Create an array of all supported standard date and time format specifiers.
string[] formats = {"d", "D", "f", "F", "g", "G", "m", "o", "r",
"s", "t", "T", "u", "U", "Y"};
// Create an array of four cultures.
CultureInfo[] cultures = {CultureInfo.CreateSpecificCulture("de-DE"),
CultureInfo.CreateSpecificCulture("en-US"),
CultureInfo.CreateSpecificCulture("es-ES"),
CultureInfo.CreateSpecificCulture("fr-FR")};
// Define date to be displayed.
DateTime dateToDisplay = new DateTime(2008, 10, 1, 17, 4, 32);
// Iterate each standard format specifier.
foreach (string formatSpecifier in formats)
{
foreach (CultureInfo culture in cultures)
Console.WriteLine("{0} Format Specifier {1, 10} Culture {2, 40}",
formatSpecifier, culture.Name,
dateToDisplay.ToString(formatSpecifier, culture));
Console.WriteLine();
}
}
}
// The example displays the following output:
// d Format Specifier de-DE Culture 01.10.2008
// d Format Specifier en-US Culture 10/1/2008
// d Format Specifier es-ES Culture 01/10/2008
// d Format Specifier fr-FR Culture 01/10/2008
//
// D Format Specifier de-DE Culture Mittwoch, 1. Oktober 2008
// D Format Specifier en-US Culture Wednesday, October 01, 2008
// D Format Specifier es-ES Culture miércoles, 01 de octubre de 2008
// D Format Specifier fr-FR Culture mercredi 1 octobre 2008
//
// f Format Specifier de-DE Culture Mittwoch, 1. Oktober 2008 17:04
// f Format Specifier en-US Culture Wednesday, October 01, 2008 5:04 PM
// f Format Specifier es-ES Culture miércoles, 01 de octubre de 2008 17:04
// f Format Specifier fr-FR Culture mercredi 1 octobre 2008 17:04
//
// F Format Specifier de-DE Culture Mittwoch, 1. Oktober 2008 17:04:32
// F Format Specifier en-US Culture Wednesday, October 01, 2008 5:04:32 PM
// F Format Specifier es-ES Culture miércoles, 01 de octubre de 2008 17:04:3
// F Format Specifier fr-FR Culture mercredi 1 octobre 2008 17:04:32
//
// g Format Specifier de-DE Culture 01.10.2008 17:04
// g Format Specifier en-US Culture 10/1/2008 5:04 PM
// g Format Specifier es-ES Culture 01/10/2008 17:04
// g Format Specifier fr-FR Culture 01/10/2008 17:04
//
// G Format Specifier de-DE Culture 01.10.2008 17:04:32
// G Format Specifier en-US Culture 10/1/2008 5:04:32 PM
// G Format Specifier es-ES Culture 01/10/2008 17:04:32
// G Format Specifier fr-FR Culture 01/10/2008 17:04:32
//
// m Format Specifier de-DE Culture 01 Oktober
// m Format Specifier en-US Culture October 01
// m Format Specifier es-ES Culture 01 octubre
// m Format Specifier fr-FR Culture 1 octobre
//
// o Format Specifier de-DE Culture 2008-10-01T17:04:32.0000000
// o Format Specifier en-US Culture 2008-10-01T17:04:32.0000000
// o Format Specifier es-ES Culture 2008-10-01T17:04:32.0000000
// o Format Specifier fr-FR Culture 2008-10-01T17:04:32.0000000
//
// r Format Specifier de-DE Culture Wed, 01 Oct 2008 17:04:32 GMT
// r Format Specifier en-US Culture Wed, 01 Oct 2008 17:04:32 GMT
// r Format Specifier es-ES Culture Wed, 01 Oct 2008 17:04:32 GMT
// r Format Specifier fr-FR Culture Wed, 01 Oct 2008 17:04:32 GMT
//
// s Format Specifier de-DE Culture 2008-10-01T17:04:32
// s Format Specifier en-US Culture 2008-10-01T17:04:32
// s Format Specifier es-ES Culture 2008-10-01T17:04:32
// s Format Specifier fr-FR Culture 2008-10-01T17:04:32
//
// t Format Specifier de-DE Culture 17:04
// t Format Specifier en-US Culture 5:04 PM
// t Format Specifier es-ES Culture 17:04
// t Format Specifier fr-FR Culture 17:04
//
// T Format Specifier de-DE Culture 17:04:32
// T Format Specifier en-US Culture 5:04:32 PM
// T Format Specifier es-ES Culture 17:04:32
// T Format Specifier fr-FR Culture 17:04:32
//
// u Format Specifier de-DE Culture 2008-10-01 17:04:32Z
// u Format Specifier en-US Culture 2008-10-01 17:04:32Z
// u Format Specifier es-ES Culture 2008-10-01 17:04:32Z
// u Format Specifier fr-FR Culture 2008-10-01 17:04:32Z
//
// U Format Specifier de-DE Culture Donnerstag, 2. Oktober 2008 00:04:32
// U Format Specifier en-US Culture Thursday, October 02, 2008 12:04:32 AM
// U Format Specifier es-ES Culture jueves, 02 de octubre de 2008 0:04:32
// U Format Specifier fr-FR Culture jeudi 2 octobre 2008 00:04:32
//
// Y Format Specifier de-DE Culture Oktober 2008
// Y Format Specifier en-US Culture October, 2008
// Y Format Specifier es-ES Culture octubre de 2008
// Y Format Specifier fr-FR Culture octobre 2008
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 分享一个免费、快速、无限量使用的满血 DeepSeek R1 模型,支持深度思考和联网搜索!
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· ollama系列01:轻松3步本地部署deepseek,普通电脑可用
· 25岁的心里话
· 按钮权限的设计及实现