[英]How I can get date correctly from sql in c#?
I need to take the time and date when a user posts a comment. 我需要记录用户发表评论的时间和日期。
So, I insert the data into the database with this code: 因此,我使用以下代码将数据插入数据库:
SqlDataSource3.InsertCommand = "Insert into [co] (datee, timee) values (@d, @t)";
String dateNow = DateTime.Now.ToShortDateString();
SqlDataSource3.InsertParameters.Add("d", dateNow);
String timeNow = DateTime.Now.ToShortTimeString();
SqlDataSource3.InsertParameters.Add("t", timeNow);
SqlDataSource3.Insert();
But its appears like the photo below: 但它看起来像下面的照片:
How I can get the date "yyyy/MM/dd" and time "HH:mm tt" 如何获取日期“ yyyy / MM / dd”和时间“ HH:mm tt”
格式化数据列表是解决方案,谢谢
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.