Now the problem is. If the System time is 07, the String shows 7,
But I need to have two numbers. Not 7 but, 07. Otherwise my program won't functioning.
My question now is, is there a way to "int" 7 = 07 or something?
Or is there a FULL method to get the time, only the time. Not the date?
Actually, thre's not even a need to convert the hour value to an int before formatting it. Using a custom time format string, you can obtain it by formatting the DateTime directly:
And, of course, there are also corresponding format strings for the minute ("mm") and the second ("ss"). Such a format string can also be used to obtain the complete time (without date) as three times two characters plus time separators by using the format string "HH:mm:ss".
Moreover, given this is the common way to write it in the current culture, this complete format is equivalent to the shorter (and culture-aware) long time format that is written as "T". Finally, as this format is used really frequently in programs, there's a DateTime method that returns a time formatted that way without the need to pass a format string at all: ToLongTimeString(). So, the straightest way to get to the complete formatted time, based on your code, would be:
Code:
String^ GrabTime()
{
DateTime GetDateTimeInfo = DateTime::Now;
return GetDateTimeInfo.ToLongTimeString(); // six digits, two separators
}
Originally Posted by Miraclezz
Solved.
This is the solving solution!
Thanks!
Fine. In this situation it's good practice (though unfortunately rarely done) to mark the thread [RESOLVED] using the Thread Tools menu at the top of the thread display, as an aid to other users seeing the thread.
Last edited by Eri523; March 17th, 2012 at 03:52 PM.
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Bookmarks