Parse and format date in c#

when use '/' in pattern, must use '\' to escape it,
when get formatted date string, use the following method:

datefrom.ToString("yyyy-MM-dd")

   1: DateTime datefrom;
   2: try
   3: {
   4:     datefrom = DateTime.ParseExact(txtFromDate.Text.Trim(), "MM\\/dd, yyyy", null); 
   5: }
   6: catch (Exception)
   7: {
   8:     datefrom = new DateTime(1900, 1, 1); 
   9: }
 
Tao obeys its own inherent Nature

posted on 2007-08-17 15:18 Wade 阅读(298) 评论(0)  编辑 收藏 网摘 所属分类: C#




发表评论

昵称: [登录] [注册]

主页:

邮箱:(仅博主可见)

评论内容:

  登录  注册

[使用Ctrl+Enter键快速提交评论]

0 859839




相关文章:

相关链接:

导航

<2007年8月>
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

与我联系

搜索

 

随笔分类

相册

Javascript

PHP

最新评论

阅读排行榜

评论排行榜