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 阅读(402) 评论(0) 编辑 收藏

导航

公告

昵称:Wade
园龄:4年5个月
粉丝:1
关注:0
<2007年8月>
2930311234
567891011
12131415161718
19202122232425
2627282930311
2345678

搜索

 
 

随笔分类

相册

Javascript

PHP

最新评论

阅读排行榜

评论排行榜

推荐排行榜