datetime to unix timestamp dart code example

Example 1: dart timestamp

void main() {
  print(new DateTime.now().millisecondsSinceEpoch);
}

Example 2: flutter get millis time

void main() {
  print(DateTime.now().millisecondsSinceEpoch);
}

Example 3: flutter date time to timestamp

DateTime currentPhoneDate = DateTime.now(); //DateTime

Timestamp myTimeStamp = Timestamp.fromDate(currentPhoneDate); //To TimeStamp

DateTime myDateTime = myTimeStamp.toDate(); // TimeStamp to DateTime

print("current phone data is: $currentPhoneDate");
print("current phone data is: $myDateTime");

Tags:

Cpp Example