Dani
Dani

Reputation: 4196

Create specific time variable in Flutter

With TimeOfDay.now() we can get the actual time, but how can we create a variable with a different time, like 12:00 for example?

I need to be able to select a DateTime manually but by default, I need to display 12pm.

Upvotes: 2

Views: 1317

Answers (2)

Harsh Bhikadia
Harsh Bhikadia

Reputation: 10885

Simply do this:

TimeOfDay(hour: 12, minute: 0)

Upvotes: 4

Viren V Varasadiya
Viren V Varasadiya

Reputation: 27197

Using String you can set custom time in following manner.

var moonLanding = DateTime.parse("2020-02-10 12:00:00Z");  
print(moonLanding.hour);

Upvotes: 1

Related Questions