从DD改变日期格式/ MM / YYYY以MM / DD / YYYY [英] changing date format from dd/MM/yyyy to MM/dd/yyyy

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

问题描述

我有一个日期选择器,显示格式为DD / MM / YYYY日期(我知道我coould改变有本身,而是由客户想用那种方式),并在数据库中其格式为MM / DD / YYYY,所以我想转换以这种方式。

I have a datepicker which shows date in format dd/MM/yyyy(i know i coould change there itself but by client want it that way) and in database its in format MM/dd/yyyy so i do want to convert in that way.

例如。在文本框中23/09/2010和升C其转换为MM / DD / YYYY(txtbo1.text)

e.g. in text box 23/09/2010 and in c sharp its convert to mm/dd/yyyy(txtbo1.text)

问候
Indranil。

Regards Indranil.

推荐答案

如果你真的存储日期作为一个数据库字符串,可以将字符串格式转换以下列方式:

If you really store the date as a string in the DB, you can convert the string format in the following manner:

DateTime.ParseExact(dateTimeString, "dd/MM/yyyy", null).ToString("MM/dd/yyyy")

这篇关于从DD改变日期格式/ MM / YYYY以MM / DD / YYYY的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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