String timeAgoFromTimestamp(int timestamp) {
  final DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(timestamp);
  final Duration diff = DateTime.now().difference(dateTime);

  if (diff.inSeconds < 60) {
    return 'Just now';
  } else if (diff.inMinutes < 60) {
    return '${diff.inMinutes} Min${diff.inMinutes > 1 ? 's' : ''} ago';
  } else if (diff.inHours < 24) {
    return '${diff.inHours} Hour${diff.inHours > 1 ? 's' : ''} ago';
  } else if (diff.inDays < 7) {
    return '${diff.inDays} Day${diff.inDays > 1 ? 's' : ''} ago';
  } else if (diff.inDays < 30) {
    int weeks = (diff.inDays / 7).floor();
    return '$weeks Week${weeks > 1 ? 's' : ''} ago';
  } else if (diff.inDays < 365) {
    int months = (diff.inDays / 30).floor();
    return '$months Month${months > 1 ? 's' : ''} ago';
  } else {
    int years = (diff.inDays / 365).floor();
    return '$years Year${years > 1 ? 's' : ''} ago';
  }
}