はじめに

この記事は、rustc 1.4.0 (8ab8581f6 2015-10-27) で動作確認しています。

rust で unixtimeを取得する

unixtime とは

協定世界時 (UTC) での1970年1月1日真夜中(午前0時0分0秒)の時刻からの形式的な経過秒数(すなわち、実質的な経過秒数から、その間に挿入された閏秒を引き、削除された閏秒を加えたもの)

— 出典: wikipedia
です。

rustでこのunixtimeを取得する方法の紹介です。

code

[dependencies]
time = "*"
extern crate time;
let now_unixtime: i64 = time::now().to_timespec().sec;

参考

Rust forum – Parsing a time string into a Unix timestamp

广告
将在 10 秒后关闭
bannerAds