Is there any way to get just the current time in DateTime format? I able to get both date and time but I just want the current time in datetime format.
Create a variable datetime variable in assign
DatetimeVar = Now
write line the DatetimeVar.toString(“dd-MM-yyyy:HH:mm:sss”)
and if you wants to learn more about date time you can refer below
I guess you didnt get my question, I just need the time(hh:mm)in Datetime format. Even I am able to get it in dd/MM/yyyy hh:mm
str1 = DateTime.Now.ToString("hh:mm")
Remove “dd/MM/yyyy” from the above format you will get the desired result!
I want it to be stored in Datetime variable and not string
it gets stored in String type right but not in date time variable. Tried converting it to Datetime but again it will be displayed as dd/MM/yyyy hh:mm
If you want to have in Datetime variable it comes with complete details with date and time
And to get that
Datetime.Now will give the current date and time
Where if you want to have only a kind of time value alone then use TIMESPAN
Have a view on this doc for more ideas with an example
Is this you are trying to achieve?
Please give a try,
Yes @prasath_S that also bring the same result as below.
@shreyaank either you can use DateTime or TimeSpan as data type and get the value as above.
@Jobin_Joy yes it’s same result but he don’t want to get it in string so converting the string into a timespan.
Yeah so simply he can parse it to TimeSpan. Thank you.