Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

date -d not working on mac

Tags:

date

linux

macos

I am trying to convert a timestamp to a number of seconds and it is not working as intended on a mac. On linux I can run:

date -d "2015-06-11 12:39" +%s and I get 1434044340 as intended. However, when I run that same command on a mac, I get

usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... 
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]

what is the corresponding mac command and/or how can I get the original command to work on a mac?

like image 206
drjrm3 Avatar asked Dec 14 '22 13:12

drjrm3


1 Answers

3 years later :) Try this: brew install coreutils ; echo "alias date=gdate" >> ~/.bash_profile Then run your command

like image 179
Lon Kaut Avatar answered Jan 01 '23 00:01

Lon Kaut