php - date 함수 사용
2024-05-24 15:10
1,731
0
0
0
본문
접기
[ ▼ 작성자 참고 Source ]
// 현재 날짜와 시간을 가져옵니다.
$currentDateTime = date("Y-m-d H:i:s");
// 연, 월, 일, 시간, 분, 초를 각각 가져옵니다.
$year = date("Y", strtotime($currentDateTime));
$month = date("m", strtotime($currentDateTime));
$day = date("d", strtotime($currentDateTime));
$hour = date("H", strtotime($currentDateTime));
$minute = date("i", strtotime($currentDateTime));
$second = date("s", strtotime($currentDateTime));
// 출력합니다.
echo "연: " . $year . "
";
echo "월: " . $month . "
";
echo "일: " . $day . "
";
echo "시간: " . $hour . "
";
echo "분: " . $minute . "
";
echo "초: " . $second . "
";
본문
위 코드는 현재 날짜와 시간을 가져와서 각각 연, 월, 일, 시간, 분, 초로 나누어 출력합니다
0
0
로그인 후 추천 또는 비추천하실 수 있습니다.
댓글목록0