(PHP 4, PHP 5, PHP 7)
mktime — ȡ��һ�����ڵ� Unix ʱ���
$hour
= date("H")
[, int $minute
= date("i")
[, int $second
= date("s")
[, int $month
= date("n")
[, int $day
= date("j")
[, int $year
= date("Y")
[, int $is_dst
= -1
]]]]]]] ) : int���ݸ����IJ������� Unix ʱ�����ʱ�����һ���������������˴� Unix ��Ԫ��January 1 1970 00:00:00 GMT��������ʱ���������
�������Դ�������ʡ�ԣ��κ�ʡ�ԵIJ����ᱻ���óɱ������ں�ʱ��ĵ�ǰֵ��
Note:
As of PHP 5.1, when called with no arguments, mktime() throws an
E_STRICT
notice: use the time() function instead.
hour
Сʱ����
The number of the hour relative to the start of the day determined by
month
, day
and year
.
Negative values reference the hour before midnight of the day in question.
Values greater than 23 reference the appropriate hour in the following day(s).
minute
��������
The number of the minute relative to the start of the hour
.
Negative values reference the minute in the previous hour.
Values greater than 59 reference the appropriate minute in the following hour(s).
second
������һ����֮�ڣ���
The number of seconds relative to the start of the minute
.
Negative values reference the second in the previous minute.
Values greater than 59 reference the appropriate second in the following minute(s).
month
�·����� The number of the month relative to the end of the previous year. Values 1 to 12 reference the normal calendar months of the year in question. Values less than 1 (including negative values) reference the months in the previous year in reverse order, so 0 is December, -1 is November, etc. Values greater than 12 reference the appropriate month in the following year(s).
day
������ The number of the day relative to the end of the previous month. Values 1 to 28, 29, 30 or 31 (depending upon the month) reference the normal days in the relevant month. Values less than 1 (including negative values) reference the days in the previous month, so 0 is the last day of the previous month, -1 is the day before that, etc. Values greater than the number of days in the relevant month reference the appropriate day in the following month(s).
year
���������������λ����λ���֣�0-69 ��Ӧ�� 2000-2069��70-100
��Ӧ�� 1970-2000�������ϵͳ���ձ�� time_t ��Ϊһ�� 32
λ�з�������������£�year
�ĺϷ���Χ�� 1901 �� 2038 ֮�䣬������������
PHP 5.1.0 ���ѱ��˷��ˡ�
is_dst
������������Ϊ 1����ʾ��������ʱ��ʱ�䣨DST����0
��ʾ������ʱ�ƣ����� -1��Ĭ��ֵ����ʾ��֪���Ƿ�����ʱ�ơ����δ֪��PHP
�᳢���Լ������ס�����ܲ�������Ԥ֪�������Dz���ȷ���Ľ�������
PHP ���е�ϵͳ�������� DST ���� is_dst
��Ϊ 1��ijЩʱ������Ч�ġ����� DST �� 2:00 ��Ч�������д���
2:00 �� 3:00 ֮���ʱ�䶼��Ч��mktime()
�᷵��һ��δ���壨ͨ��Ϊ������ֵ��ijЩϵͳ������
Solaris 8���� DST ����ҹ��Ч���� DST ��Ч����� 0:30
�ᱻ����Ϊǰһ��� 23:30��
Note:
�� PHP 5.1.0 �𣬱������ѱ�������Ӧ��ʹ���µ�ʱ�����������������
Note:
PHP 7.0.0 �𣬴˲����Ѿ����Ƴ���
mktime() ���ݸ����IJ������� Unix
ʱ�������������Ƿ�������������
FALSE
���� PHP 5.1 ֮ǰ���� -1����
��ÿ �ε�������/ʱ�亯��ʱ�����ʱ����Ч������� E_NOTICE
�������ʹ��ϵͳ�趨ֵ�� TZ
����������������� E_STRICT
�� E_WARNING
��Ϣ���μ�
date_default_timezone_set()��
�汾 | ˵�� |
---|---|
7.0.0 |
is_dst �����Ѿ����Ƴ���
|
5.3.0 |
mktime() now throws E_DEPRECATED notice
if the is_dst parameter is used.
|
5.1.0 |
is_dst ����������������ʱ��������
FALSE �������� -1�������˱��������Խ��������ղ���ȫΪ�㡣
|
5.1.0 |
When called with no arguments, mktime() throws
E_STRICT notice. Use the
time() function instead.
|
5.1.0 |
���ڷ��� |
Example #1 ��������
<?php
// Set the default timezone to use. Available as of PHP 5.1
date_default_timezone_set('UTC');
// Prints: July 1, 2000 is on a Saturday
echo "July 1, 2000 is on a " . date("l", mktime(0, 0, 0, 7, 1, 2000));
// Prints something like: 2006-04-05T01:02:03+00:00
echo date('c', mktime(1, 2, 3, 4, 5, 2006));
?>
Example #2 mktime() ����
mktime() �������ڼ������֤��������ã������Զ����㳬����Χ���������ȷֵ����������������ÿһ�ж�������ַ��� "Jan-01-1998"��
<?php
echo date("M-d-Y", mktime(0, 0, 0, 12, 32, 1997));
echo date("M-d-Y", mktime(0, 0, 0, 13, 1, 1997));
echo date("M-d-Y", mktime(0, 0, 0, 1, 1, 1998));
echo date("M-d-Y", mktime(0, 0, 0, 1, 1, 98));
?>
Example #3 �¸��µ����һ��
�κθ����·ݵ����һ�춼���Ա���ʾΪ�¸��µĵ� "0" �죬������ -1 �졣�����������Ӷ�������ַ��� "The last day in Feb 2000 is: 29"��
<?php
$lastday = mktime(0, 0, 0, 3, 0, 2000);
echo strftime("Last day in Feb 2000 is: %d", $lastday);
$lastday = mktime(0, 0, 0, 4, -31, 2000);
echo strftime("Last day in Feb 2000 is: %d", $lastday);
?>
�� PHP 5.1.0 ֮ǰ�����κ���֪ Windows �汾�Լ�һЩ����ϵͳ�²�֧�ָ���ʱ����������ݵ���Ч��Χ����Ϊ 1970 �� 2038��