Current time

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.

1 Like

Hi @shreyaank

Create a variable datetime variable in assign

DatetimeVar = Now

write line the DatetimeVar.toString(“dd-MM-yyyy:HH:mm:sss”)

Regards

1 Like

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")
2 Likes

@shreyaank

Remove “dd/MM/yyyy” from the above format you will get the desired result!

Regards

1 Like

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

1 Like

Hi @shreyaank

Is this you are trying to achieve?

image

Thank you.

Hi @shreyaank,

Please give a try,

Timespan.parse(Now.tostring("hh:mm:ss"))

Thanks

Yes @prasath_S that also bring the same result as below.

image

@shreyaank either you can use DateTime or TimeSpan as data type and get the value as above.

Thank you.

1 Like

@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.