skip to Main Content

I have created a flutter app and I need the time for calculating future but cannot get actual time i.e. DateTime.timestamp() showing the time 11:23 but in device showing the time 15:51 my device is Galaxy A20s.

2

Answers


  1. DateTime now = DateTime.now(); 
    

    You can use this for current time, I hope this may help you.

    Login or Signup to reply.
  2. This gets me the right value, including timezone offset:

    final DateTime now = DateTime.now();
    final String formattedTime = DateFormat.yMd().add_jms().format(now);
    print(formattedTime);
    

    You may have to change the DateFormat for your locale.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search