DateTime的格式如下:2016-01-13T11:11:11Z [英] DateTime in following format: 2016-01-13T11:11:11Z

查看:32
本文介绍了DateTime的格式如下:2016-01-13T11:11:11Z的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将DateTime转换为以下格式:

I'm trying to convert my DateTime to the following format:

例如:

2016-01-13T11:11:11Z

但是ToString("u")给出了 2016-01-13 11:11:11Z

But ToString("u") gives 2016-01-13 11:11:11Z

在日期和时间之间也需要字母 T .有没有办法做到这一点?

I need the letter T also between date and time. Is there a way to accomplish this?

推荐答案

您可以直接使用以下格式提供T:

You can supply the T directly in the format like this:

Console.WriteLine(DateTime.Now.ToString("yyyy-MM-ddThh:mm:ssZ"));

这将为您提供所需的T和Z.

This will give you the T and Z you are looking for.

这篇关于DateTime的格式如下:2016-01-13T11:11:11Z的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆