Label1.Text = DateTime.Parse(rowView["AddTime"].ToString()).ToShortDateString();
Label2.Text = (Convert.ToDateTime(rowView["AddTime"])).ToString("yyyy-MM-dd");
本文介绍了两种不同的方法来将数据库中获取的时间字符串转换为易于阅读的日期格式。一种方法使用了DateTime.Parse结合ToShortDateString()方法,另一种则利用了Convert.ToDateTime配合ToString()方法指定了日期格式。这两种方法均可实现日期格式的标准化展示。
Label1.Text = DateTime.Parse(rowView["AddTime"].ToString()).ToShortDateString();
Label2.Text = (Convert.ToDateTime(rowView["AddTime"])).ToString("yyyy-MM-dd");
3308

被折叠的 条评论
为什么被折叠?