skip to Main Content

I can’t define empty datetime in dart. And I don’t know the answer to this question

I looked on the internet but couldn’t find any solution.

3

Answers


  1. DateTime emptyDateTime = DateTime.fromMillisecondsSinceEpoch(0);
    

    outputs the value :

    1970-01-01 00:00:00.000
    
    Login or Signup to reply.
  2. I think it would be better make it null-able .

    DateTime? date;
    

    More about null-safety

    Login or Signup to reply.
  3. Another way. First second of our era.

    final date = DateTime(1);
    print(date);
    

    Output:

    0001-01-01 00:00:00.000

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