C#中的Datetime对象 [英] Datetime object in C#

查看:311
本文介绍了C#中的Datetime对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我陷入了某些日期格式问题.

我有一些string,无论我的机器日期文化如何,我都必须将其转换为格式为(yyyy-MM-dd)date对象(因为我想将该日期传递给仅接受(yyyy-MM-dd)格式的日期的Web服务)

I am stuck in some date formating.

I am having some string which I have to convert into date object with format (yyyy-MM-dd), irrespective of my machine date culture(because I want to pass that date to some webservice which accept date only in(yyyy-MM-dd) format)

推荐答案

看看这个:
自定义日期和时间格式字符串 [
Take a look at this:
Custom Date and Time Format Strings[^]

Regards
Espen Harlinn


如果您有字符串,则基本上需要重新格式化该字符串以适合所需的格式. DateTime 对象本身没有与之关联的格式.它不在内部存储为字符串.也许您的意思是您有一个DateTime 对象,并且您想要从中提取特定的字符串格式.如果是这样,那是可能的.只需使用适当的ToString 重载即可.
If you have a string, then you basically need to reformat that string to fit your required format. The DateTime object itself does not have a format associated with it. It''s not internally stored as a string. Perhaps you mean that you have a DateTime object and you want to extract a specific string format from that. If so, that''s possible. Just use an appropriate ToString overload.


查看下面的文章

DateTime的字符串格式[C#]


如果发现有用,请接受答案:)
Check out below article

String Format for DateTime [C#]


Accept the answer if find useful :)


这篇关于C#中的Datetime对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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