Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
3
Help us understand the problem. What is going on with this article?
@jshimazu

MacOSとLinuxのdateコマンドの違い

More than 3 years have passed since last update.

Datestring↔Timestampの変換はdateコマンドでやることが多いのだが、
Linux系OSとMacOSそれぞれのbashの方言の違いにハマったのでメモ。

GNU (e.g. Linux OS)

# To Timestamp
date -d "2008-10-1 12:34" +%s
# To Datestring
date --date "@1104505200"

BSD (e.g. Mac OS)

# To Timestamp
date -r "1104505200"

# To Datestring
date -j -f "%Y-%m-%d" "2010-10-02" "+%s"
3
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
jshimazu
流しのエンジニア DMM.com → 面白法人カヤック → Pivolab(フリーランス) 守備範囲はWebならだいたいOK、フロントエンドが得意です。 PHP / Ruby / Python / Javascript / HTML / CSS / Ruby on Rails / React / Vue.js / AWS / GCP

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
3
Help us understand the problem. What is going on with this article?