checkdate
��������� ������������ ����/�������.
��������� :
int checkdate(int month, int day, int year);
������� checkdate() ��������� ������������ ����, �������� � �� ����������.
���������� true ���� ����, ��������� ��� "month, day, year" (�����, �����, ���), ���������, ����� false. ���� ��������� ����������, ����:
- ��� ����� 1 � 32767 ������������
- ����� ����� 1 � 12 ������������
- ���� ��������� � ��������� ����������� ���� ������� ������. ���������� ���� �����������.
��������� ������������ ����/�������.
��������� :
int checkdate(int month, int day, int year);
������� checkdate() ��������� ������������ ����, �������� � �� ����������.
���������� true ���� ����, ��������� ��� "month, day, year" (�����, �����, ���), ���������, ����� false. ���� ��������� ����������, ����:
- ��� ����� 1 � 32767 ������������
- ����� ����� 1 � 12 ������������
- ���� ��������� � ��������� ����������� ���� ������� ������. ���������� ���� �����������.
$month=1; $day=10; $year=2002; if(checkdate($month,$day,$year)) echo "����� ���� ����!"; else echo "������ ��� ���!";�������: ����� ���� ����!
$month=13; $day=10; $year=2002; if(checkdate($month,$day,$year)) echo "����� ���� ����!"; else echo "������ ��� ���!";�������: ������ ��� ���!
date
������ ���������� �������/����.
��������� :
string date(string format [, int timestamp]);
��� ������� ���������� ������, ���������� ���� � �����, ����������������� �������� ������ format � ��������� ��������� ����� timestamp ��� ������� ��������� �����, ���� �� ������ ��������� �����.
������ "Z" ������ ���������� 0 ��� ������������� � �������� gmdate().
������ ���������� �������/����.
��������� :
string date(string format [, int timestamp]);
��� ������� ���������� ������, ���������� ���� � �����, ����������������� �������� ������ format � ��������� ��������� ����� timestamp ��� ������� ��������� �����, ���� �� ������ ��������� �����.
- � �������� ������ ������ �������������� ��������� �������:
- a - "��" � "�����" �������: "am" ��� "pm"
- A - "��" � "�����" �������: "AM" ��� "PM"
- d - ���� ������, 2 ����� (�� ������ ����� ����) (�� 01 �� 31)
- D - ���� ������, ���������, 3 �����; �.�. "Fri"
- j - ���� ������, 1-2 ����� ��� ��������� ����� (�� 1 �� 31)
- F - �����, ���������, �������; �.�. "January"
- h - ���, 12-������� ������ (�� 01 �� 12)
- H - ���, 24-������� ������ (�� 00 �� 23)
- g - ���, 12-������� ������ ��� ����� (�� 1 �� 12)
- G - ���, 24-������� ������ ��� ����� (�� 0 �� 23)
- i - ������ (�� 00 �� 59)
- I(������� i) - 1, ���� ��������� ������� �� ������ �����, ����� 0
- L - 0, ���� ��� �� ����������, ��� 1 � ��������� ������
- B - Swatch Internet time
- T - ��������� ���� ����������, ��������: MDT (�������� �� ������)
- l (�������� "L") - ���� ������, ���������, �������; �.�. "Friday"
- m - �����, ��� ����� � ������ (�� 01 �� 12)
- n - �����, ����-��� ����� ��� ����� (�� 1 �� 12)
- M - ������������� ���������� ���������� ������; �.�. "Jan"
- t - ����� ���� � ��������� ������ (�� 28 �� 31)
- s - ������� (�� 0 �� 59)
- S - ������������ ���������� ������� ����� �� ���� ����, ���������, �.�. "th", "nd"
- U - ����� ����� ������, ��������� � ������� ������ ����� UNIX (�������� �� ������)
- Y - ���, ��������, 4 ����� (1999)
- y - ���, ��������, 2 ����� (99)
- w - ���������� ����� ��� � ������,(�� 0-����������� �� 6-�������)
- z - ���������� ����� ��� � ���� (�� 0 �� 365)
- Z - �������� ��������� ���� � ��������� (�� -43200 �� 43200)
- a - "��" � "�����" �������: "am" ��� "pm"
������ "Z" ������ ���������� 0 ��� ������������� � �������� gmdate().
echo date("������� d.m.Y"); //������� 31.01.2002 echo date( "l dS of F Y h:i:s A" ); // Thursday 31st of January 2002 12:51:19 PM echo "July 1, 2000 is on a " . date("l", mktime(0,0,0,7,1,2000)); // July 1, 2000 is on a Saturday������� date() � mktime() �������� ������������ ������ ��� ����, ����� ����� ���� � ������� ��� �������.
$tomorrow = mktime(0,0,0,date("m") ,date("d")+1,date("Y")); $lastmonth = mktime(0,0,0,date("m")-1,date("d"), date("Y")); $nextyear = mktime(0,0,0,date("m"), date("d"), date("Y")+1);
localtime
�������� ���������� � ����/�������.
��������� :
array localtime([int timestamp [, bool is_associative]]);
������ �������������� �������� ���� ������� ������ ����� ������� Unix. � ������, ���� �� �� ������, �� ������������ ������� �����.
���� ������ �������������� �������� ����� ���� (�� ���������), �� ������������ ������ ����� �������� ������������; � ��������� ������ ������������ ������������� ������, ��� �������� ����� ��������� ��������:([1])"tm_sec" - �������
([2])"tm_min" - ������
([3])"tm_hours" - ����
([4])"tm_mday" - ���� ������
([5])"tm_mon" - ����� � ����
([6])"tm_year" - ���, ��������
([7])"tm_wday" - ���� ������
([8])"tm_yday" - ���� � ����
([9])"tm_isdst" - ������� �� ������� �� ������ �����
�������� ���������� � ����/�������.
��������� :
array localtime([int timestamp [, bool is_associative]]);
������ �������������� �������� ���� ������� ������ ����� ������� Unix. � ������, ���� �� �� ������, �� ������������ ������� �����.
���� ������ �������������� �������� ����� ���� (�� ���������), �� ������������ ������ ����� �������� ������������; � ��������� ������ ������������ ������������� ������, ��� �������� ����� ��������� ��������:
gettimeofday
�������� ���� ��������� �������.
��������� :
array gettimeofday();
��� ������� ���������� ������������� ������, ������� �������� ����, ������������ ��������� �������. ������� �������� ����������� ��������� ������� gettimeofday(2).
������������ ������������� ������ �������� ��������� ��������:"sec" - �������
"usec" - ������������
"minuteswest" - �������� � ������ �� ��������, � �������
"dsttime" - ��� dst ��������� (������� �� ������ �����)
�������� ���� ��������� �������.
��������� :
array gettimeofday();
��� ������� ���������� ������������� ������, ������� �������� ����, ������������ ��������� �������. ������� �������� ����������� ��������� ������� gettimeofday(2).
������������ ������������� ������ �������� ��������� ��������:
strftime
����������� ����� �������� ��������� ����������.
��������� :
string strftime(string format [, int timestamp]);
���������� ������, ����������������� �������� ������ ��������� ������ format � ��������� ������ ��������� ����� timestamp ��� ������� ��������� �����, ���� ����� �� ������.
�������� setlocale() ����� ��������� ����, �� ������� ����� ���������� �������� ������� � ����.
� ��������� ������ ������� ������������ ��������� ������������� ��������������:
����������� ����� �������� ��������� ����������.
��������� :
string strftime(string format [, int timestamp]);
���������� ������, ����������������� �������� ������ ��������� ������ format � ��������� ������ ��������� ����� timestamp ��� ������� ��������� �����, ���� ����� �� ������.
�������� setlocale() ����� ��������� ����, �� ������� ����� ���������� �������� ������� � ����.
� ��������� ������ ������� ������������ ��������� ������������� ��������������:
- %a - ����������� �������� ��� ������ �� ��������� (Wed);
- %A - ������ �������� ��� ������ �� ��������� (Wednesday);
- %b - ����������� �������� ������ �� ��������� (Apr);
- %B - ������ �������� ������ �� ��������� (April);
- %c - ���������������� ������������� ���� � ������� (06/19/02 15:45:11);
- %C - ����� ���� (���, �������� �� 100 � ��� ������� �����, �� 00 �� 99);
- %d - ���� ������ ��� ���������� ����� (� ��������� �� 0 �� 31);
- %D - ���������� %m/%d/%y;
- %e - ����� ������ (������ ����������� ���� �������� ������) (�� 1 �� 31);
- %h - ������ %b;
- %H - ��� ��� ���������� ����� � 24-������� ������� (� ��������� �� 00 �� 23);
- %I - ��� ��� ���������� ����� � 12-������� ������� (� ��������� �� 01 �� 12);
- %j - ����� ��� � ���� ��� ���������� ����� (� ��������� �� 001 �� 366);
- %m - ����� ������ ��� ���������� ����� (� ��������� �� 1 �� 12);
- %M - ������ ��� ���������� �����;
- %n - ������ �������� �� ����� ������;
- %p - "am" ��� "pm" (�� � ����� �������) �������� �������� �������;
- %r - ����� � 12-������� ������� (a.m. ��� p.m.);
- %R - ����� � 24-������� �������;
- %S - ������� ��� ���������� �����;
- %t - ������ ���������;
- %T - ������� �����, ������������ %H:%M:$S;
- %u - ����� ��� � ������ (�� 1 �� 7) (����������� - 1);
- %U - ����� ������ � ���� ��� ���������� �����, ������� � ������� ����������� � �������� ������� ��� ������ ������;
- %V - ����� ������ � ���� �� ��������� ISO 8601:1988 (�� 1 �� 53), ��� ������ ������ - ��, � ������� ������������� ������ 3-� ���� � ������� ����;
- %W - ����� ������ � ���� ��� ���������� �����, ������� � ������� ������������ � �������� ������� ��� ������ ������;
- %w - ����� ��� � ������ (�� 0 �� 6) (����������� - 0);
- %x - ������������� ���� � ��������� ������� ��� �������� ������� (06/13/02);
- %X - ������������� ������� � ��������� ������� ��� �������� ���� (15:34:54);
- %y - ��� ��� ���������� ����� ��� �������� (� ��������� �� 00 �� 99);
- %Y - ��� ��� ���������� �����, ������� ��������;
- %Z - ��������� ���� ��� �������� ��� ����������;
- %% - ������ "%".
- %a - ����������� �������� ��� ������ �� ��������� (Wed);
setlocale ("LC_TIME", "C"); print(strftime("%A in Finnish is ")); setlocale ("LC_TIME", "fi"); print(strftime("%A, in French ")); setlocale ("LC_TIME", "fr"); print(strftime("%A and in German ")); setlocale ("LC_TIME", "de"); print(strftime("A.\n"));����������� ��������� ����� �������� ���������� locale.
getdate
�������� ���������� � ����/�������.
��������� :
array getdate(int timestamp);
���������� ������������� ������, ���������� ���������� � ���� �� ���������� ����������:
"seconds" - �������
"minutes" - ������
"hours" - ����
"mday" - ���� ������
"wday" - ���� ������, ��������
"mon" - �����, ��������
"year" - ���, ��������
"yday" - ���� ����, ��������; �.�. "299"
"weekday" - ���� ������, ���������, ������; �.�. "Friday"
"month" - �����, ���������, ������; �.�. "January"
0 - "UNIX timestamp", ���������� ��������.
�������� ���������� � ����/�������.
��������� :
array getdate(int timestamp);
���������� ������������� ������, ���������� ���������� � ���� �� ���������� ����������:
print_r(getdate(time()));����������� ������ ������� ���������:
Array ( [seconds] => 23 [minutes] => 44 [hours] => 22 [mday] => 15 [wday] => 0 [mon] => 8 [year] => 2004 [yday] => 227 [weekday] => Sunday [month] => August [0] => 1092595463 )
gmdate
��������� ���� � ��������������� ������ ��� ������� GMT.
��������� :
string gmdate(string format, int timestamp);
���������� ������� date() �� ����������� ����, ��� ����� ������������ � ����������� ������� Greenwich Mean Time (GMT). ��������, ��� ������� � ��������� (GMT +0200), ������ ������ ���� ���������� "Jan 01 1998 00:00:00", � �� ����� ��� ������ ������ ���������� "Dec 31 1997 22:00:00".
��������� ���� � ��������������� ������ ��� ������� GMT.
��������� :
string gmdate(string format, int timestamp);
���������� ������� date() �� ����������� ����, ��� ����� ������������ � ����������� ������� Greenwich Mean Time (GMT). ��������, ��� ������� � ��������� (GMT +0200), ������ ������ ���� ���������� "Jan 01 1998 00:00:00", � �� ����� ��� ������ ������ ���������� "Dec 31 1997 22:00:00".
echo date( "M d Y H:i:s",mktime(0,0,0,1,1,1998) ); echo gmdate( "M d Y H:i:s",mktime(0,0,0,1,1,1998) );
gmstrftime
�������������� ��������� �������/����.
��������� :
string gmstrftime(string format, int timestamp);
�������� ���� ������� ���������� �������� ������� strftime() � ��� ��������, ��� ������������ ����� �� �������� (GMT).
��������, ��� ������� � ���� (GMT -0500) ������ ������ ���� ���������: "Dec 31 1998 20:00:00", � ������: " Jan 01 1999 01:00:00".
�������������� ��������� �������/����.
��������� :
string gmstrftime(string format, int timestamp);
�������� ���� ������� ���������� �������� ������� strftime() � ��� ��������, ��� ������������ ����� �� �������� (GMT).
��������, ��� ������� � ���� (GMT -0500) ������ ������ ���� ���������: "Dec 31 1998 20:00:00", � ������: " Jan 01 1999 01:00:00".
setlocale("LC_TIME", "en_US"); echo strftime("%b %d %Y %H:%M:%S", mktime(20,0,0,12,31,98))."\n"; echo gmstrftime("%b %d %Y %H:%M:%S", mktime(20,0,0,12,31,98))."\n";
mktime
�������� ��������� ����� UNIX ��� ����.
��������� :
int mktime([int hour] [,int minute] [,int second] [,int month] [,int day] [,int year] [, int is_dst]);
���������� ��������� ����� Unix �������� ������ ����������. ��� ��������� ����� �������� ����� ������, ������ ���������� ������ ����� ������ Unix (1 ������ 1970) � ��������� ��������.
��� �������� ��� ������� �������������, �� ���������� �� ����� ������ ������ ������. ���� �����-�� ��������� �� ������, �� �� ����� ������������� ��������, ��������������� ������� ����.
�������� is_dst, ���������, ����������� �� ������� �� ������ ����� (1) ��� ��� (0); ���� �� ��������, �� �������� - (-1)
������� ���������� timestamp, ��������������� ��������� ����.
������������ ����, ���������� � ����������, �� �����������. � ������ ������������ ���� ������ ���������� �� ���������� - ������� "������ ���", ��� �� �� ��������, � ��������� ��������������� timestamp.
�������� ��������� ����� UNIX ��� ����.
��������� :
int mktime([int hour] [,int minute] [,int second] [,int month] [,int day] [,int year] [, int is_dst]);
���������� ��������� ����� Unix �������� ������ ����������. ��� ��������� ����� �������� ����� ������, ������ ���������� ������ ����� ������ Unix (1 ������ 1970) � ��������� ��������.
��� �������� ��� ������� �������������, �� ���������� �� ����� ������ ������ ������. ���� �����-�� ��������� �� ������, �� �� ����� ������������� ��������, ��������������� ������� ����.
�������� is_dst, ���������, ����������� �� ������� �� ������ ����� (1) ��� ��� (0); ���� �� ��������, �� �������� - (-1)
������� ���������� timestamp, ��������������� ��������� ����.
������������ ����, ���������� � ����������, �� �����������. � ������ ������������ ���� ������ ���������� �� ���������� - ������� "������ ���", ��� �� �� ��������, � ��������� ��������������� timestamp.
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) ); // ������������ ����������� ��� ���������� �����
gmmktime
������ ������� time() ��� ������� GMT.
��������� :
int gmmktime(int hour, int minute, int second, int month, int day, int year [, int is_dst]);
��������� mktime() �� ����������� ����, ��� ������������ ��������� �������� ����� �� �������� (GMT).
������ ������� time() ��� ������� GMT.
��������� :
int gmmktime(int hour, int minute, int second, int month, int day, int year [, int is_dst]);
��������� mktime() �� ����������� ����, ��� ������������ ��������� �������� ����� �� �������� (GMT).
time
��������� ������� � ��������.
��������� :
int time();
���������� ������� �����, ���������� � ����� ������ � ����� Unix (1 ������ 1970 00:00:00 GMT).
���� ������ ������ ������ � Unix ��� ����������� (���������� "UNIX timestamp"): � ���������, ����� ���������� ��������� ������ ����������� ������ � ����� �������. ������ ������, ����� ��� ������� �� ������ �� �������� ����� ���� ������ � ����� ��� �������������� (������� ���������� timestamp). �� ���� ������������� " ���������� ������ � 1 ������ 1970 ����" ������ ������������ �, ��� �������, - ������.
��������� ������� � ��������.
��������� :
int time();
���������� ������� �����, ���������� � ����� ������ � ����� Unix (1 ������ 1970 00:00:00 GMT).
���� ������ ������ ������ � Unix ��� ����������� (���������� "UNIX timestamp"): � ���������, ����� ���������� ��������� ������ ����������� ������ � ����� �������. ������ ������, ����� ��� ������� �� ������ �� �������� ����� ���� ������ � ����� ��� �������������� (������� ���������� timestamp). �� ���� ������������� " ���������� ������ � 1 ������ 1970 ����" ������ ������������ �, ��� �������, - ������.
echo time();
microtime
���������� ������� ��������� ����� UNIX � �������������.
��������� :
string microtime();
���������� ������ "msec sec" ��� sec ������� �����, ���������� � ����� ������ � ����� Unix (0:00:00 1 ������, 1970 GMT), � msec - ��� ����� � �������������. ��� ������� �������� ������ � ������������ ��������, �������������� ��������� ����� gettimeofday().
�� ���� � ���, ��� ����������� � ��������� OC �������� �� �������. �������� � Unix ��� ������������� ����� �����������, � � Windows - ���������� ��������.
���������� ������� ��������� ����� UNIX � �������������.
��������� :
string microtime();
���������� ������ "msec sec" ��� sec ������� �����, ���������� � ����� ������ � ����� Unix (0:00:00 1 ������, 1970 GMT), � msec - ��� ����� � �������������. ��� ������� �������� ������ � ������������ ��������, �������������� ��������� ����� gettimeofday().
�� ���� � ���, ��� ����������� � ��������� OC �������� �� �������. �������� � Unix ��� ������������� ����� �����������, � � Windows - ���������� ��������.
echo microtime(); // � Windows ������� ���-�� ���� 0.53033200 1012468870
strtotime
����������� �������������� ������ ������� � Unix timestamp.
��������� :
int strtotime(string time [, int now]);
� ��������� time ������� �������� ���� � ������������ �������, � ����� ����������� �� � ������������� ������ Unix timestamp.
����������� �������������� ������ ������� � Unix timestamp.
��������� :
int strtotime(string time [, int now]);
� ��������� time ������� �������� ���� � ������������ �������, � ����� ����������� �� � ������������� ������ Unix timestamp.
echo strtotime("now")."\n"; echo strtotime("10 September 2002")."\n"; echo strtotime("+2 day")."\n"; echo strtotime("+3 week")."\n"; echo strtotime("+1 week 2 days 4 hours 34 seconds")."\n";