• Visual Basic TimeStamp, time only
    6 replies, posted
I'm using visual basic 2008 express edition and I want to have a timestamp with only the time. but I don't know what to do, I know about the DateTime function, but that includes the date which is what I don't want. Dim time as System.DateTime = DateTime.Now There IS a selection for the hour, but it says Cannot convert type "Date" to "Integer" Any help would be appreciated
[code] Dim time As DateTime = DateTime.Now Dim timestamp As String = String.Concat(time.Hour, ":", time.Minute, ":", time.Second) [/code]This should work.
thanks! edit: What command would be for AM/PM? and im doing this for school (really lame and basic programming), to make a program that you can select what you want to eat at your cafeteria and it'll calculate taxes and stuff and i want somewhere to say "It is breakfast" or "It is lunch" etc., based on what time it is. So i could theoretically make timestamp a string and make hour, minute, and second a single, and am/pm a string so that i can go If sngAm/pm = "AM" and sngHour = <12 then lblCourseType.text = "It is breakfast" Endif Does this look good? will it work?
Ewwww Hungarian Notation
Hungarian notation should say in Pawn where it belongs
You can use DateTime.Now.ToString("HH:mm:ss") :).
TimeOfDay might be a useful function for you.
Sorry, you need to Log In to post a reply to this thread.