Created
April 25, 2016 04:13
-
-
Save hirokazumiyaji/9ce49088d9bc12b42134e77ab84ead94 to your computer and use it in GitHub Desktop.
最終ログインが 30 分以内か
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$user = array( | |
'id' => 1, | |
'last_logged_in_at' => date('Y-m-d H:i:s', strtotime('-20 minute')) | |
); | |
$now = new DateTimeImmutable(); | |
$latLoggedInAt = DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $user['last_logged_in_at']); | |
if ($now.diff($lastLoggedInAt) <= 30) { | |
echo '30 分以内。' . "¥n"; | |
} else { | |
echo '30 分以内ではない。' . "¥n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment