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
0
Help us understand the problem. What is going on with this article?
@tamahimesama_007

【PHP】DateTimeクラスのインスタンス呼び出しから、日付文字列出力までワンラインで書く方法

More than 1 year has passed since last update.

毎回毎回忘れてしまうので個人的なメモです。

PHPで日付時刻の文字列を出すときは、dateでやってしまえば手っ取り早いけど。

今回は、DateTimeクラスで、1行1発で出力させる方法です。

echo (new DateTime())->format('Y-m-d H:i:s');
0
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
tamahimesama_007
バッドノウハウ作るなら達人です。

Comments

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