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.
Hi @shreyaank
Create a variable datetime variable in assign
DatetimeVar = Now
write line the DatetimeVar.toString(“dd-MM-yyyy:HH:mm:sss”)
Regards
Hi!
try this
DateTime.Now.ToString("hh:mm:ss")
and if you wants to learn more about date time you can refer below
Regards,
NaNi
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
like this?
str1 = DateTime.Now.ToString("hh:mm")
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
Hi
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
Cheers @shreyaank
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.
Thank you.
@Jobin_Joy yes it’s same result but he don’t want to get it in string so converting the string into a timespan.
Thanks
Yeah so simply he can parse it to TimeSpan. Thank you.