转换日期时间为ISO格式YYYY-MM-DD HH:MM:SS在C# [英] Convert dateTime to ISO format yyyy-mm-dd hh:mm:ss in C#
本文介绍了转换日期时间为ISO格式YYYY-MM-DD HH:MM:SS在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有.NET / C#一种标准的方式为datetime对象转换为 ISO 8601 格式YYYY-MM -dd HH:MM:?SS
Is there a standard way in .NET/C# to convert a datetime object to ISO 8601 format yyyy-mm-dd hh:mm:ss?
或者我需要做一些字符串操作来获得日期字符串
Or do I need to do some string manipulation to get the date string?
推荐答案
有是可读8601格式没有标准格式。您可以使用自定义格式为:
There is no standard format for the readable 8601 format. You can use a custom format:
theDate.ToString("yyyy-MM-dd HH':'mm':'ss")
(标准格式S会给你一个T日期和之间时间,而不是一个空格。)
(The standard format "s" will give you a "T" between the date and the time, not a space.)
这篇关于转换日期时间为ISO格式YYYY-MM-DD HH:MM:SS在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文