LoginSignup
0
0

More than 1 year has passed since last update.

【C#】手っ取り早くUnixtimeをJSTに変換する

Posted at

Timezoneとかやりだすとめんどくさい、JSTが+9なことくらいわかってる

ワンライナーできないのが残念(できないことはないかも?)

var dateTimeOffset = DateTimeOffset.FromUnixTimeSeconds(unixTime);
dateTimeOffset = dateTimeOffset.ToOffset(new TimeSpan(+9, 0, 0)); // set to JST
dateTimeOffset.ToString("yyyy-MM-dd HH:mm:ss"); // 2022-01-01 12:31:55

SQL形式もスパッと変換してほしい…

0
0
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0