ASP中DD/MM/yyyy的日期时间转换 [英] Date time convertion of DD/MM/yyyy in asp

查看:84
本文介绍了ASP中DD/MM/yyyy的日期时间转换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在asp.net中将日期格式从dd/mm/yyyy转换为mm/dd/yyyy

How to convert Date format from dd/MM/yyyy to mm/dd/yyyy in asp.net

推荐答案

下面的代码将执行该操作.

Below code will perform it.

String OriginalDate = "08/30/1999";
DateTime temp = Convert.ToDateTime(OriginalDate.Text);
String ConvertDate = temp.ToString("dd/MM/yyyy"); // or "MM/dd/yyyy"



作为替代解决方案,您可以设置适当的CurtureInfo来将日期字符串解析为DateTime

有趣的线程位于 http://forums.asp.net/thread/1557498.aspx [



As the alternative solution, you can set appropriate CurtureInfo to parse your date string to DateTime

Interesting thread at http://forums.asp.net/thread/1557498.aspx[^]


请尝试以下代码.

Try as below code.

DateTime dtNow = DateTime.Now;

string MonthDayYear = dtNow.ToString("MM/dd/yyyy");
string DayMonthYear = dtNow.ToString("dd/MM/yyyy");


使用此

use this

datetime.now.tostring("MM/dd/yyyy");



知道所有格式都通过此链接
http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8- F859AA20581F.htm [ ^ ]



to know all the formats go through this link
http://www.geekzilla.co.uk/View00FF7904-B510-468C-A2C8-F859AA20581F.htm[^]


这篇关于ASP中DD/MM/yyyy的日期时间转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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