1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977
|
<?xml version="1.0" encoding="utf-8"?>
<reference id="ref.datetime">
<title>Date and Time functions</title>
<titleabbrev>Date/time</titleabbrev>
<refentry id="function.checkdate">
<refnamediv>
<refname>checkdate</refname>
<refpurpose>Validate a gregorian date/time</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>checkdate</methodname>
<methodparam><type>int</type><parameter>month</parameter></methodparam>
<methodparam><type>int</type><parameter>day</parameter></methodparam>
<methodparam><type>int</type><parameter>year</parameter></methodparam>
</methodsynopsis>
<para>
Returns &true; if the date given is valid; otherwise returns &false;.
Checks the validity of the date formed by the arguments. A date
is considered valid if:
<itemizedlist>
<listitem>
<simpara>
year is between 1 and 32767 inclusive
</simpara>
</listitem>
<listitem>
<simpara>
month is between 1 and 12 inclusive
</simpara>
</listitem>
<listitem>
<simpara>
<parameter>Day</parameter> is within the allowed number of
days for the given <parameter>month</parameter>. Leap
<parameter>year</parameter>s are taken into consideration.
</simpara>
</listitem>
</itemizedlist>
</para>
</refsect1>
</refentry>
<refentry id="function.date">
<refnamediv>
<refname>date</refname>
<refpurpose>Format a local time/date</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>date</methodname>
<methodparam><type>string</type><parameter>format</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>
timestamp
</parameter></methodparam>
</methodsynopsis>
<para>
Returns a string formatted according to the given format string
using the given <parameter>timestamp</parameter> or the current
local time if no timestamp is given.
</para>
<para>
The following characters are recognized in the format string:
<itemizedlist>
<listitem>
<simpara>
a - "am" or "pm"
</simpara>
</listitem>
<listitem>
<simpara>
A - "AM" or "PM"
</simpara>
</listitem>
<listitem>
<simpara>
B - Swatch Internet time
</simpara>
</listitem>
<listitem>
<simpara>
d - day of the month, 2 digits with leading zeros; i.e. "01"
to "31"
</simpara>
</listitem>
<listitem>
<simpara>
D - day of the week, textual, 3 letters; i.e. "Fri"
</simpara>
</listitem>
<listitem>
<simpara>
F - month, textual, long; i.e. "January"
</simpara>
</listitem>
<listitem>
<simpara>
g - hour, 12-hour format without leading zeros; i.e. "1" to
"12"
</simpara>
</listitem>
<listitem>
<simpara>
G - hour, 24-hour format without leading zeros; i.e. "0" to
"23"
</simpara>
</listitem>
<listitem>
<simpara>
h - hour, 12-hour format; i.e. "01" to "12"
</simpara>
</listitem>
<listitem>
<simpara>
H - hour, 24-hour format; i.e. "00" to "23"
</simpara>
</listitem>
<listitem>
<simpara>
i - minutes; i.e. "00" to "59"
</simpara>
</listitem>
<listitem>
<simpara>
I (capital i) - "1" if Daylight Savings Time, "0" otherwise.
</simpara>
</listitem>
<listitem>
<simpara>
j - day of the month without leading zeros; i.e. "1" to "31"
</simpara>
</listitem>
<listitem>
<simpara>
l (lowercase 'L') - day of the week, textual, long;
i.e. "Friday"
</simpara>
</listitem>
<listitem>
<simpara>
L - boolean for whether it is a leap year; i.e. "0" or "1"
</simpara>
</listitem>
<listitem>
<simpara>
m - month; i.e. "01" to "12"
</simpara>
</listitem>
<listitem>
<simpara>
M - month, textual, 3 letters; i.e. "Jan"
</simpara>
</listitem>
<listitem>
<simpara>
n - month without leading zeros; i.e. "1" to "12"
</simpara>
</listitem>
<listitem>
<simpara>
r - RFC 822 formatted date; i.e. "Thu, 21 Dec 2000 16:01:07 +0200"
</simpara>
</listitem>
<listitem>
<simpara>
s - seconds; i.e. "00" to "59"
</simpara>
</listitem>
<listitem>
<simpara>
S - English ordinal suffix, textual, 2 characters; i.e. "th",
"nd"
</simpara>
</listitem>
<listitem>
<simpara>
t - number of days in the given month; i.e. "28" to "31"
</simpara>
</listitem>
<listitem>
<simpara>
T - Timezone setting of this machine; i.e. "MDT"
</simpara>
</listitem>
<listitem>
<simpara>
U - seconds since the epoch
</simpara>
</listitem>
<listitem>
<simpara>
w - day of the week, numeric, i.e. "0" (Sunday) to "6"
(Saturday)
</simpara>
</listitem>
<listitem>
<simpara>
Y - year, 4 digits; i.e. "1999"
</simpara>
</listitem>
<listitem>
<simpara>
y - year, 2 digits; i.e. "99"
</simpara>
</listitem>
<listitem>
<simpara>
z - day of the year; i.e. "0" to "365"
</simpara>
</listitem>
<listitem>
<simpara>
Z - timezone offset in seconds (i.e. "-43200" to "43200"). The
offset for timezones west of UTC is always negative, and for
those east of UTC is always positive.
</simpara>
</listitem>
</itemizedlist>
Unrecognized characters in the format string will be printed
as-is. The "Z" format will always return "0" when using
<function>gmdate</function>.
<example>
<title><function>date</function> example</title>
<programlisting role="php">
print (date ("l dS of F Y h:i:s A"));
print ("July 1, 2000 is on a " . date ("l", mktime(0,0,0,7,1,2000)));
</programlisting>
</example>
</para>
<para>
It is possible to use <function>date</function> and
<function>mktime</function> together to find dates in the future
or the past.
<example>
<title>
<function>date</function> and <function>mktime</function>
example
</title>
<programlisting>
$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);
</programlisting>
</example>
</para>
<para>
To format dates in other languages, you should use the
<function>setlocale</function> and <function>strftime</function>
functions.
</para>
<para>
See also <function>gmdate</function> and
<function>mktime</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.getdate">
<refnamediv>
<refname>getdate</refname>
<refpurpose>Get date/time information</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>getdate</methodname>
<methodparam choice="opt"><type>int</type><parameter>timestamp</parameter></methodparam>
</methodsynopsis>
<para>
Returns an associative array containing the date information of
the <parameter>timestamp</parameter>, or the current local time if
no timestamp is given, as the following array
elements:
<itemizedlist>
<listitem>
<simpara>
"seconds" - seconds
</simpara>
</listitem>
<listitem>
<simpara>
"minutes" - minutes
</simpara>
</listitem>
<listitem>
<simpara>
"hours" - hours
</simpara>
</listitem>
<listitem>
<simpara>
"mday" - day of the month
</simpara>
</listitem>
<listitem>
<simpara>
"wday" - day of the week, numeric
</simpara>
</listitem>
<listitem>
<simpara>
"mon" - month, numeric
</simpara>
</listitem>
<listitem>
<simpara>
"year" - year, numeric
</simpara>
</listitem>
<listitem>
<simpara>
"yday" - day of the year, numeric; i.e. "299"
</simpara>
</listitem>
<listitem>
<simpara>
"weekday" - day of the week, textual, full; i.e. "Friday"
</simpara>
</listitem>
<listitem>
<simpara>
"month" - month, textual, full; i.e. "January"
</simpara>
</listitem>
</itemizedlist>
</para>
</refsect1>
</refentry>
<refentry id="function.gettimeofday">
<refnamediv>
<refname>gettimeofday</refname>
<refpurpose>Get current time</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>gettimeofday</methodname>
<void/>
</methodsynopsis>
<para>
This is an interface to gettimeofday(2). It returns an
associative array containing the data returned from the system
call.
<itemizedlist>
<listitem>
<simpara>
"sec" - seconds
</simpara>
</listitem>
<listitem>
<simpara>
"usec" - microseconds
</simpara>
</listitem>
<listitem>
<simpara>
"minuteswest" - minutes west of Greenwich
</simpara>
</listitem>
<listitem>
<simpara>
"dsttime" - type of dst correction
</simpara>
</listitem>
</itemizedlist>
</para>
</refsect1>
</refentry>
<refentry id="function.gmdate">
<refnamediv>
<refname>gmdate</refname>
<refpurpose>Format a GMT/CUT date/time</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>gmdate</methodname>
<methodparam><type>string</type><parameter>format</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>timestamp</parameter></methodparam>
</methodsynopsis>
<para>
Identical to the <function>date</function> function except that
the time returned is Greenwich Mean Time (GMT). For example, when
run in Finland (GMT +0200), the first line below prints "Jan 01
1998 00:00:00", while the second prints "Dec 31 1997 22:00:00".
<example>
<title><function>gmdate</function> example</title>
<programlisting role="php">
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));
</programlisting>
</example>
</para>
<para>
See also <function>date</function>, <function>mktime</function>,
and <function>gmmktime</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.gmmktime">
<refnamediv>
<refname>gmmktime</refname>
<refpurpose>Get UNIX timestamp for a GMT date</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>gmmktime</methodname>
<methodparam><type>int</type><parameter>hour</parameter></methodparam>
<methodparam><type>int</type><parameter>minute</parameter></methodparam>
<methodparam><type>int</type><parameter>second</parameter></methodparam>
<methodparam><type>int</type><parameter>month</parameter></methodparam>
<methodparam><type>int</type><parameter>day</parameter></methodparam>
<methodparam><type>int</type><parameter>year</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>is_dst</parameter></methodparam>
</methodsynopsis>
<para>
Identical to <function>mktime</function> except the passed
parameters represents a GMT date.
</para>
</refsect1>
</refentry>
<refentry id="function.gmstrftime">
<refnamediv>
<refname>gmstrftime</refname>
<refpurpose>
Format a GMT/CUT time/date according to locale settings
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>gmstrftime</methodname>
<methodparam><type>string</type><parameter>format</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>timestamp</parameter></methodparam>
</methodsynopsis>
<para>
Behaves the same as <function>strftime</function> except that the
time returned is Greenwich Mean Time (GMT). For example, when run
in Eastern Standard Time (GMT -0500), the first line below prints
"Dec 31 1998 20:00:00", while the second prints "Jan 01 1999
01:00:00".
<example>
<title><function>gmstrftime</function> example</title>
<programlisting role="php">
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";
</programlisting>
</example>
</para>
<para>
See also <function>strftime</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.localtime">
<refnamediv>
<refname>localtime</refname>
<refpurpose>Get the local time</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>array</type><methodname>localtime</methodname>
<methodparam choice="opt"><type>int</type><parameter>
timestamp
</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>
is_associative
</parameter></methodparam>
</methodsynopsis>
<para>
The <function>localtime</function> function returns an array
identical to that of the structure returned by the C function
call. The first argument to <function>localtime</function> is
the timestamp, if this is not given the current time is used.
The second argument to the <function>localtime</function> is the
<parameter>is_associative</parameter>, if this is set to 0 or not
supplied than the array is returned as a regular, numerically
indexed array. If the argument is set to 1 then
<function>localtime</function> is an associative array containing
all the different elements of the structure returned by the C
function call to localtime. The names of the different keys of
the associative array are as follows:
<itemizedlist>
<listitem>
<simpara>
"tm_sec" - seconds
</simpara>
</listitem>
<listitem>
<simpara>
"tm_min" - minutes
</simpara>
</listitem>
<listitem>
<simpara>
"tm_hour" - hour
</simpara>
</listitem>
<listitem>
<simpara>
"tm_mday" - day of the month
</simpara>
</listitem>
<listitem>
<simpara>
"tm_mon" - month of the year
</simpara>
</listitem>
<listitem>
<simpara>
"tm_year" - Year, not y2k compliant
</simpara>
</listitem>
<listitem>
<simpara>
"tm_wday" - Day of the week
</simpara>
</listitem>
<listitem>
<simpara>
"tm_yday" - Day of the year
</simpara>
</listitem>
<listitem>
<simpara>
"tm_isdst" - Is daylight savings time in effect
</simpara>
</listitem>
</itemizedlist>
</para>
</refsect1>
</refentry>
<refentry id="function.microtime">
<refnamediv>
<refname>microtime</refname>
<refpurpose>
Return current UNIX timestamp with microseconds</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>microtime</methodname>
<void/>
</methodsynopsis>
<para>
Returns the string "msec sec" where sec is the current time
measured in the number of seconds since the Unix Epoch (0:00:00
January 1, 1970 GMT), and msec is the microseconds part. This
function is only available on operating systems that support the
gettimeofday() system call.
</para>
<para>
See also <function>time</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.mktime">
<refnamediv>
<refname>mktime</refname>
<refpurpose>Get UNIX timestamp for a date</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>mktime</methodname>
<methodparam><type>int</type><parameter>hour</parameter></methodparam>
<methodparam><type>int</type><parameter>minute</parameter></methodparam>
<methodparam><type>int</type><parameter>second</parameter></methodparam>
<methodparam><type>int</type><parameter>month</parameter></methodparam>
<methodparam><type>int</type><parameter>day</parameter></methodparam>
<methodparam><type>int</type><parameter>year</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>is_dst</parameter></methodparam>
</methodsynopsis>
<para>
<emphasis>Warning:</emphasis> Note the strange order of
arguments, which differs from the order of arguments in a regular
UNIX mktime() call and which does not lend itself well to leaving
out parameters from right to left (see below). It is a common
error to mix these values up in a script.
</para>
<para>
Returns the Unix timestamp corresponding to the arguments
given. This timestamp is a long integer containing the number of
seconds between the Unix Epoch (January 1 1970) and the time
specified.
</para>
<para>
Arguments may be left out in order from right to left; any
arguments thus omitted will be set to the current value according
to the local date and time.
</para>
<para>
<parameter>Is_dst</parameter> can be set to 1 if the time is
during daylight savings time, 0 if it is not, or -1 (the default)
if it is unknown whether the time is within daylight savings time
or not.
</para>
<note>
<para>
<parameter>Is_dst</parameter> was added in 3.0.10.
</para>
</note>
<para>
<function>mktime</function> is useful for doing date arithmetic
and validation, as it will automatically calculate the correct
value for out-of-range input. For example, each of the following
lines produces the string "Jan-01-1998".
<example>
<title><function>mktime</function> example</title>
<programlisting>
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));
</programlisting>
</example>
<parameter>Year</parameter> may be a two or four digit value,
with values between 0-69 mapping to 2000-2069 and 70-99 to
1970-1999 (on systems where time_t is a 32bit signed integer, as
most common today, the valid range for
<parameter>year</parameter> is somewhere between 1902 and 2037).
</para>
<para>
The last day of any given month can be expressed as the "0" day
of the next month, not the -1 day. Both of the following examples
will produce the string "The last day in Feb 2000 is: 29".
<example>
<title>Last day of next month</title>
<programlisting role="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);
</programlisting>
</example>
</para>
<simpara>
Date with year, month and day equal to zero is considered illegal
(otherwise it what be regarded as 30.11.1999, which would be strange
behaviour).
</simpara>
<para>
See also <function>date</function> and <function>time</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.strftime">
<refnamediv>
<refname>strftime</refname>
<refpurpose>
Format a local time/date according to locale settings
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>strftime</methodname>
<methodparam><type>string</type><parameter>format</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>
timestamp
</parameter></methodparam>
</methodsynopsis>
<para>
Returns a string formatted according to the given format string
using the given <parameter>timestamp</parameter> or the current
local time if no timestamp is given. Month and weekday names and
other language dependent strings respect the current locale set
with <function>setlocale</function>.
</para>
<para>
The following conversion specifiers are recognized in the format
string:
<itemizedlist>
<listitem>
<simpara>
%a - abbreviated weekday name according to the current locale
</simpara>
</listitem>
<listitem>
<simpara>
%A - full weekday name according to the current locale
</simpara>
</listitem>
<listitem>
<simpara>
%b - abbreviated month name according to the current locale
</simpara>
</listitem>
<listitem>
<simpara>
%B - full month name according to the current locale
</simpara>
</listitem>
<listitem>
<simpara>
%c - preferred date and time representation for the current
locale
</simpara>
</listitem>
<listitem>
<simpara>
%C - century number (the year divided by 100 and truncated to
an integer, range 00 to 99)
</simpara>
</listitem>
<listitem>
<simpara>
%d - day of the month as a decimal number (range 01 to 31)
</simpara>
</listitem>
<listitem>
<simpara>
%D - same as %m/%d/%y
</simpara>
</listitem>
<listitem>
<simpara>
%e - day of the month as a decimal number, a single digit is
preceded by a space (range ' 1' to '31')
</simpara>
</listitem>
<listitem>
<simpara>
%h - same as %b
</simpara>
</listitem>
<listitem>
<simpara>
%H - hour as a decimal number using a 24-hour clock (range 00
to 23)
</simpara>
</listitem>
<listitem>
<simpara>
%I - hour as a decimal number using a 12-hour clock (range 01
to 12)
</simpara>
</listitem>
<listitem>
<simpara>
%j - day of the year as a decimal number (range 001 to 366)
</simpara>
</listitem>
<listitem>
<simpara>
%m - month as a decimal number (range 01 to 12)
</simpara>
</listitem>
<listitem>
<simpara>
%M - minute as a decimal number
</simpara>
</listitem>
<listitem>
<simpara>
%n - newline character
</simpara>
</listitem>
<listitem>
<simpara>
%p - either `am' or `pm' according to the given time value, or
the corresponding strings for the current locale
</simpara>
</listitem>
<listitem>
<simpara>
%r - time in a.m. and p.m. notation
</simpara>
</listitem>
<listitem>
<simpara>
%R - time in 24 hour notation
</simpara>
</listitem>
<listitem>
<simpara>
%S - second as a decimal number
</simpara>
</listitem>
<listitem>
<simpara>
%t - tab character
</simpara>
</listitem>
<listitem>
<simpara>
%T - current time, equal to %H:%M:%S
</simpara>
</listitem>
<listitem>
<simpara>
%u - weekday as a decimal number [1,7], with 1 representing
Monday
</simpara>
</listitem>
<listitem>
<simpara>
%U - week number of the current year as a decimal number,
starting with the first Sunday as the first day of the first
week
</simpara>
</listitem>
<listitem>
<simpara>
%V - The ISO 8601:1988 week number of the current year as a
decimal number, range 01 to 53, where week 1 is the first
week that has at least 4 days in the current year, and with
Monday as the first day of the week.
</simpara>
</listitem>
<listitem>
<simpara>
%W - week number of the current year as a decimal number,
starting with the first Monday as the first day of the first
week
</simpara>
</listitem>
<listitem>
<simpara>
%w - day of the week as a decimal, Sunday being 0
</simpara>
</listitem>
<listitem>
<simpara>
%x - preferred date representation for the current locale
without the time
</simpara>
</listitem>
<listitem>
<simpara>
%X - preferred time representation for the current locale
without the date
</simpara>
</listitem>
<listitem>
<simpara>
%y - year as a decimal number without a century (range 00 to
99)
</simpara>
</listitem>
<listitem>
<simpara>
%Y - year as a decimal number including the century
</simpara>
</listitem>
<listitem>
<simpara>
%Z - time zone or name or abbreviation
</simpara>
</listitem>
<listitem>
<simpara>
%% - a literal `%' character
</simpara>
</listitem>
</itemizedlist>
<note>
<para>
Not all conversion specifiers may be supported by your C
library, in which case they will not be supported by PHP's
<function>strftime</function>.
</para>
</note>
<example>
<title><function>strftime</function> example</title>
<programlisting role="php">
setlocale ("LC_TIME", "C");
print (strftime ("%A in Finnish is "));
setlocale ("LC_TIME", "fi_FI");
print (strftime ("%A, in French "));
setlocale ("LC_TIME", "fr_CA");
print (strftime ("%A and in German "));
setlocale ("LC_TIME", "de_DE");
print (strftime ("%A.\n"));
</programlisting>
</example>
This example works if you have the respective locales installed
in your system.
</para>
<para>
See also <function>setlocale</function> and
<function>mktime</function> and the <ulink url="&spec.strftime;">
Open Group specification of
<function>strftime</function></ulink>.
</para>
</refsect1>
</refentry>
<refentry id="function.time">
<refnamediv>
<refname>time</refname>
<refpurpose>Return current UNIX timestamp</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>time</methodname>
<void/>
</methodsynopsis>
<para>
Returns the current time measured in the number of seconds since
the Unix Epoch (January 1 1970 00:00:00 GMT).
</para>
<para>
See also <function>date</function>.
</para>
</refsect1>
</refentry>
<refentry id="function.strtotime">
<refnamediv>
<refname>strtotime</refname>
<refpurpose>
Parse about any english textual datetime description into a UNIX
timestamp
</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>strtotime</methodname>
<methodparam><type>string</type><parameter>time</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>now</parameter></methodparam>
</methodsynopsis>
<para>
The function expects to be given a string containing an english
date format and will try to parse that format into a UNIX
timestamp.
<example>
<title><function>strtotime</function> examples</title>
<programlisting role="php">
echo strtotime ("now") . "\n";
echo strtotime ("10 September 2000") . "\n";
echo strtotime ("+1 day") . "\n";
echo strtotime ("+1 week") . "\n";
echo strtotime ("+1 week 2 days 4 hours 2 seconds") . "\n";
</programlisting>
</example>
</para>
</refsect1>
</refentry>
</reference>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
-->
|