Convert unix epoch time to human readable date on Mac OSX – BSD

Here you go: # date -r 123439819723 ‘+%m/%d/%Y:%H:%M:%S’ 08/26/5881:17:48:43 In a bash script you could have something like this: if [[ “$OSTYPE” == “linux-gnu”* ]]; then dayOfWeek=$(date –date @1599032939 +”%A”) dateString=$(date –date @1599032939 +”%m/%d/%Y:%H:%M:%S”) elif [[ “$OSTYPE” == “darwin”* ]]; then dayOfWeek=$(date -r 1599032939 +%A) dateString=$(date -r 1599032939 +%m/%d/%Y:%H:%M:%S) fi

Convert a column of datetimes to epoch in Python

convert the string to a datetime using to_datetime and then subtract datetime 1970-1-1 and call dt.total_seconds(): In [2]: import pandas as pd import datetime as dt df = pd.DataFrame({‘date’:[‘2011-04-24 01:30:00.000’]}) df Out[2]: date 0 2011-04-24 01:30:00.000 In [3]: df[‘date’] = pd.to_datetime(df[‘date’]) df Out[3]: date 0 2011-04-24 01:30:00 In [6]: (df[‘date’] – dt.datetime(1970,1,1)).dt.total_seconds() Out[6]: 0 1303608600 … Read more

Is a day always 86,400 epoch seconds long?

Whenever doing calendrical calculations, it is almost always better to use whatever API the platform provides, such as Python’s datetime and calendar modules, or a mature high-quality library, than it is to write “simpler” code yourself. Date and calendar APIs are ugly and complicated, but that’s because real-world calendars have a lot of weird behavior. … Read more

Convert Epoch Time to Date PHP

Fixed it using substr($epoch, 0, 10) and then used the date function for anyone wondering about the 13 digit epoch times. Here is a sample code: echo date(“Y-m-d H:i:s”, substr(“1477020641000”, 0, 10)); // Result: 2016-10-20 20:30:41

Converting epoch number to human readable date in mysql

Your epoch value 1389422614485 seems like having the millisecond precision. So you need to use some mysql mathematical functions along with from_unixtime() for generating human readable format. mysql> select from_unixtime(floor(1389422614485/1000)); +——————————————+ | from_unixtime(floor(1389422614485/1000)) | +——————————————+ | 2014-01-11 12:13:34 | +——————————————+ Update July 2020: As of MySQL 8.0, the floor function is no longer necessary when … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)