xxxxxxxxxx
String sdatetime = "2021-12-04";
DateTime sdate = DateTime.parse(sdatetime);
int stimestamp = sdate.microsecondsSinceEpoch;
print(stimestamp); //output: 1638555300000000
xxxxxxxxxx
from datetime import datetime
string_date = "2022-01-01 12:34:56"
format_string = "%Y-%m-%d %H:%M:%S"
timestamp = datetime.strptime(string_date, format_string)
print(timestamp)
xxxxxxxxxx
from datetime import datetime
# current date and time
now = datetime.now()
timestamp = datetime.timestamp(now)
print("timestamp =", timestamp)
xxxxxxxxxx
int ts = 1638592424384;
DateTime tsdate = DateTime.fromMillisecondsSinceEpoch(timestamp);
String fdatetime = DateFormat('dd-MMM-yyy').format(tsdate); //DateFormat() is from intl package
print(fdatetime); //output: 04-Dec-2021
xxxxxxxxxx
date -d @xxxxxxxxxx
# use the first 10 digits of the timestamp in place of the x'es.