0
0

More than 3 years have passed since last update.

sprintfで書式を整える

Posted at

$date = sprintf('%04d年 %02d月 %02d日', 2021, 5, 13);
print($date);

//%の後の数字(04etc)で表記する桁数を指示している
//dは数字の意味で、数字以外が記入されたときにエラーで弾くようになっている。
//※これだけで万全ではないので、注意

//文字を書きたいときは、d→sに変更するとOK

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