日期格式问题 [英] issue on Date Format

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

问题描述

在我的应用程序中,显示日期格式为dd/MM/yyyy,而我的客户端计算机的日期时间格式为MM/dd/yyyy,因此我的应用程序抛出错误数据时间转换,请帮我这个问题

in My Application Display Date Format Is dd/MM/yyyy and my client computer Date time format is MM/dd/yyyy so My Application is Throw Error Data time Convert please help me This Proble

推荐答案

使用....
DateTime.ParseExact(sampledatetime,"dd/MM/yyyy hh:mm:ss tt",CultureInfo.InvariantCulture);
use ....
DateTime.ParseExact (sampledatetime,"dd/MM/yyyy hh:mm:ss tt" ,CultureInfo.InvariantCulture );


尝试使用DateTime.ParseExact ,格式为
try with DateTime.ParseExact with format
DateTime convertedDate = DateTime.ParseExact(inputDateString, dd/MM/yyyy, CultureInfo.InvariantCulture);


不要依赖特定的DateTime格式:在计算机的区域"和语言"设置中设置的本地计算机的标准"格式.然后,当以典型"格式输入日期时,DateTime.Parse/TryParse将起作用.
Do not rely on a specific DateTime format: the "standard" format for the local computer as set in Regional and Language settings of the computer. Then DateTime.Parse/TryParse will work when the Date was entered with the "typical" format.


这篇关于日期格式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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