I am trying to get the current time:
date = "(" + DateTime.Today.Year.ToString() + "-" +
DateTime.Today.Month.ToString() + "-" + DateTime.Today.Day.ToString() + " " +
"(" + DateTime.Today.Hour.ToString() + ":" + DateTime.Today.Minute.ToString()
+")" + ")";
This should get a date like:
(2013-2-1 (13:01))
But it give me:
(2013-2-1 (0:0))
How can i fix this?
You’re using
DateTime.Todaywhich is documented as:So yes, if you find the
HourandMinutecomponents, they will be 0…If you want the current time of day, use
DateTime.Nowinstead. Note that bothTodayandNowuse the system-local time zone – you need to be sure that that really is what you want to use. (It’s probably fine for a local client app, but not for a web app.)