Como converter o tempo epoch em uma data legível por humanos?
import datetime# Convert epoch to human readable dateepoch = 1631532000human_readable_date = datetime.datetime.utcfromtimestamp(epoch).strftime('%Y-%m-%d %H:%M:%S')print(human_readable_date)
// Convert epoch to human readable dateconst epoch = 1631532000;const humanReadableDate = new Date(epoch * 1000).toISOString().replace(/T|Z/g, ' ');console.log(humanReadableDate);
import java.text.SimpleDateFormat;import java.util.Date;// Convert epoch to human readable datelong epoch = 1631532000;Date date = new Date(epoch * 1000);SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");String humanReadableDate = sdf.format(date);System.out.println(humanReadableDate);
using System;// Convert epoch to human readable datelong epoch = 1631532000;DateTime date = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(epoch);string humanReadableDate = date.ToString("yyyy-MM-dd HH:mm:ss");Console.WriteLine(humanReadableDate);
#include <iostream>#include <chrono>#include <ctime>int main() {// Convert epoch to human readable datelong epoch = 1631532000;std::time_t time = epoch;std::tm* tm = std::gmtime(&time);char buffer[80];std::strftime(buffer, 80, "%Y-%m-%d %H:%M:%S", tm);std::cout << buffer << std::endl;return 0;}
<?php// Convert epoch to human readable date$epoch = 1631532000;$humanReadableDate = date('Y-m-d H:i:s', $epoch);echo $humanReadableDate;?>
// Convert epoch to human readable dateconst epoch = 1631532000;const humanReadableDate = new Date(epoch * 1000).toISOString().replace(/T|Z/g, ' ').slice(0, -5);console.log(humanReadableDate);
import Foundation// Convert epoch to human readable datelet epoch = 1631532000let date = Date(timeIntervalSince1970: TimeInterval(epoch))let dateFormatter = DateFormatter()dateFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss"let humanReadableDate = dateFormatter.string(from: date)print(humanReadableDate)
# Convert epoch to human readable dateepoch = 1631532000human_readable_date = Time.at(epoch).strftime('%Y-%m-%d %H:%M:%S')puts human_readable_date
package mainimport ("fmt""time")func main() {// Convert epoch to human readable dateepoch := int64(1631532000)humanReadableDate := time.Unix(epoch, 0).Format("2006-01-02 15:04:05")fmt.Println(humanReadableDate)}