Firebase Datetime to Timestamp

Custom Code

Hey,

I'm trying to create a function to convert a Datetime field from a Firestore collection into a Timestamp but everything I try gets me a different error message. How should I do it ?

Here's the version that I think brings me closest to what I'm trying to achieve:

import 'dart:convert';
import 'dart:math' as math;

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:timeago/timeago.dart' as timeago;
import '/flutter_flow/lat_lng.dart';
import '/flutter_flow/place.dart';
import '/flutter_flow/uploaded_file.dart';
import '/flutter_flow/custom_functions.dart';
import '/backend/backend.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
import '/auth/firebase_auth/auth_util.dart';

int? dateTimeToTimeStamp(DateTime? dateTime) {
  /// MODIFY CODE ONLY BELOW THIS LINE

  var timestamp = format(dateTime.getTime());
  return (timestamp);

  /// MODIFY CODE ONLY ABOVE THIS LINE
}
What have you tried so far?

Lots of searching and trying

Did you check FlutterFlow's Documentation for this topic?
Yes
1
11 replies