�yStep6�z ���t�Ǝ����@

�o�g�o�ɂ́A���t�Ǝ������삷��֐������炩���ߗp�ӂ���Ă��܂��B

getdate()�֐��@

�����̓��t(���ԁj�����߂܂��B

�s�\���t

getdate (timestamp)

getdate()�֐��́A���̕������v�f�Ƃ���A�z�z���Ԃ��܂��B

second ���݂̕b
minutes ���݂̕�
hours ���݂̎���
mday ���݂̓�
wday ���݂̗j���ԍ�
mon ���݂̌�
year ���݂̔N
yday ���̔N�̒ʎZ��
weekday �e�L�X�g�`���̗j��
month �e�L�X�g�`���̌�

�s�T���v���t

<?php
�@�@$today = getdate();
�@�@echo ("�����̓��t�� $today[year]�N$today[mon]��$today[mday]��<br>\n");
�@�@echo ("$today[weekday] $today[month]/$today[mday]/$today[year]<br>\n");
�@�@echo ("���N��1��1������ $today[yday]���ڂł�");
?>

�s���s���ʁt

�����̓��t�� 2024�N12��17��
Tuesday December/17/2024
���N��1��1������ 351���ڂł�

���������i�j�֐��@

�����ŗ^�������t���w�肷��t�H�[�}�b�g��������ɕϊ����܂��B

a am �܂��� pm
A AM �܂��� PM
d �Q���̓��t(01�`31)
D �R�����̗j�� (Sun �` Sat)
F �t���X�y���̉p���̌�(January�`December)
h 12���ԒP�� (00 �` 12) �̎���
H 24���ԒP�� (00 �` 23) �̎���
g �擪�� 0 ���‚��Ȃ�12���ԒP�� (0 �` 12)
G �擪�� 0 ���‚��Ȃ�24���ԒP�� (0 �` 23)
I 2���̕� (00 �` 59)
j �擪�� 0 ���‚��Ȃ� (0 �` 31)�̓�
l �t���X�y���̉p���ŗj��(Sunday�`Saturday)
L �[�N�ł� 1 ���A����ȊO�� 0 ��Ԃ�
n �擪�� 0 ���‚��Ȃ� (0 �` 12) �̌�
m �Q���̂̌� (01 �` 12)
M �R�����̌� (Jan �` Dec)
s �Q���̕b (00 �` 59)
S �p���̏�����\�킷�ڔ��� (th �` nd)
t �w�肵�����̓��� (28 �` 31)
U UNIX���� (1970�N1��1������̕b��)
w ���l�Ŏ����j�� (0 �` 6)
y ����̉��Q���������N
Y ������S���Ŏ����N
z ���̔N��1��1������̒ʎZ��
Z �^�C���]�[���̃I�t�Z�b�g�b ( -43200 �` 43200�܂Łj

�s�T���v���t

<?php
�@�@$hiduke = date("Y/m/d");
�@�@echo ("$hiduke<br>\n");
�@�@$hiduke = date("Y/m/d H:i:s a");
�@�@echo ("$hiduke<br>\n");
�@�@$hiduke = date("y/n/j G:i:s");
�@�@echo ("$hiduke<br>\n");
�@�@$hiduke = date("Y F l");
�@�@echo ("$hiduke<br>\n");
?>

�s���s���ʁt

2024/12/17
2024/12/17 11:37:24 am
24/12/17 11:37:24
2024 December Tuesday

 

���t�v�f����^�C���X�^���v���擾�����@

mktime()�֐����g���ƁA���t/��������^�C���X�^���v�i�o�ߓ���/�����j���v�Z���Ă���܂��B

<?php
//���t�Ǝ�����ݒ�
$hour = 11;
$minute = 59;
$second = 59;
$mm = 11;
$dd = 5;
$yyyy = 2005;

//�^�C���X�^���v���擾
echo "�w����F $yyyy �N $mm �� $dd �� $hour �� $minute �� $second �b<br>";
echo "�^�C���X�^���v�F".mktime($hour,$minute,$second,$mm,$dd,$yyyy);

//���t���ȗ������^�C���X�^���v
$time = mktime($hour,$minute,$second);
echo "<p>�^�C���X�^���v�F $time<br>";
echo "�����F".date("Y/m/d H:i:s", $time);
?>

 

�w�������������̓��t�����߂��@

mktime()�֐����g���āA���̃p�����[�^���u�w����{�o�ߓ����v�Ƃ���ƁA�o�ߓ�����̓��t�����߂邱�Ƃ��ł��܂��B

<?php
//�{���̓��t
$today = getdate();
$yyyy = $today[year];
$mm = $today[mon];
$dd = $today[mday];

//�Ԋu����
$kankaku = 30;

//�^�C���X�^���v���擾
$date = date("Y/m/d", mktime(0,0,0, $mm,$dd + $kankaku,$yyyy));
echo "$yyyy �N $mm �� $dd �� �� $kankaku ���� ���@".$date ;
?>

 

�����̓��t�����߂��@

mktime()�֐��ŁA�u���v�Ɂu�O�v���w�肷��ƁA�O�����̓��t���擾���邱�Ƃ��ł��܂��B�u���v�{�P�ŁA�����������߂邱�Ƃ��ł��܂��B

<?php
//�����̓��t�����߂�
$today = getdate();
$yyyy = $today[year];
$mm = $today[mon];
$kongetu = $mm + 1;


$date = date("Y/m/d", mktime(0,0,0, $mm,0,$yyyy));
echo "$yyyy �N $mm �� 1 �� �� �O�� ���@".$date."(�O�����j" ;

$date = date("Y/m/d", mktime(0,0,0, $mm + 1,0,$yyyy));
echo "<p>$yyyy �N $kongetu �� 1 �� �� �O�� ���@".$date."(�������j" ;
?>