1<?php
2/* Unix Timestamp */
3$timestamp = time();
4echo $timestamp . "<br>";
5echo date("d/m/Y", $timestamp);
6?>
1
2<?php
3// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the
4// Mountain Standard Time (MST) Time Zone
5
6$today = date("F j, Y, g:i a"); // March 10, 2001, 5:16 pm
7$today = date("m.d.y"); // 03.10.01
8$today = date("j, n, Y"); // 10, 3, 2001
9$today = date("Ymd"); // 20010310
10$today = date('h-i-s, j-m-y, it is w Day'); // 05-16-18, 10-03-01, 1631 1618 6 Satpm01
11$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day.
12$today = date("D M j G:i:s T Y"); // Sat Mar 10 17:16:18 MST 2001
13$today = date('H:m:s \m \i\s\ \m\o\n\t\h'); // 17:03:18 m is month
14$today = date("H:i:s"); // 17:16:18
15$today = date("Y-m-d H:i:s"); // 2001-03-10 17:16:18 (the MySQL DATETIME format)
16?>
17
18
1echo date('d/m/Y h:i:s a'); // 01/02/2020 01:01:30 am
2// d - The day of the month (from 01 to 31)
3// D - A textual representation of a day (three letters)
4// j - The day of the month without leading zeros (1 to 31)
5// l (lowercase 'L') - A full textual representation of a day
6// N - The ISO-8601 numeric representation of a day (1 for Monday, 7 for Sunday)
7// S - The English ordinal suffix for the day of the month (2 characters st, nd, rd or th. Works well with j)
8// w - A numeric representation of the day (0 for Sunday, 6 for Saturday)
9// z - The day of the year (from 0 through 365)
10// W - The ISO-8601 week number of year (weeks starting on Monday)
11// F - A full textual representation of a month (January through December)
12// m - A numeric representation of a month (from 01 to 12)
13// M - A short textual representation of a month (three letters)
14// n - A numeric representation of a month, without leading zeros (1 to 12)
15// t - The number of days in the given month
16// L - Whether it's a leap year (1 if it is a leap year, 0 otherwise)
17// o - The ISO-8601 year number
18// Y - A four digit representation of a year
19// y - A two digit representation of a year
20// a - Lowercase am or pm
21// A - Uppercase AM or PM
22// B - Swatch Internet time (000 to 999)
23// g - 12-hour format of an hour (1 to 12)
24// G - 24-hour format of an hour (0 to 23)
25// h - 12-hour format of an hour (01 to 12)
26// H - 24-hour format of an hour (00 to 23)
27// i - Minutes with leading zeros (00 to 59)
28// s - Seconds, with leading zeros (00 to 59)
29// u - Microseconds (added in PHP 5.2.2)
30// e - The timezone identifier (Examples: UTC, GMT, Atlantic/Azores)
31// I (capital i) - Whether the date is in daylights savings time (1 if Daylight Savings Time, 0 otherwise)
32// O - Difference to Greenwich time (GMT) in hours (Example: +0100)
33// P - Difference to Greenwich time (GMT) in hours:minutes (added in PHP 5.1.3)
34// T - Timezone abbreviations (Examples: EST, MDT)
35// Z - Timezone offset in seconds. The offset for timezones west of UTC is negative (-43200 to 50400)
36// c - The ISO-8601 date (e.g. 2013-05-05T16:34:42+00:00)
37// r - The RFC 2822 formatted date (e.g. Fri, 12 Apr 2013 12:01:05 +0200)
38// U - The seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
1Return the current time as a Unix timestamp, then format it to a date:
2<?php
3/* Unix Timestamp */
4$timestamp = time();
5echo $timestamp . "<br>";
6echo date("d/m/Y", $timestamp);
7?>
1
2<?php
3$nextWeek = time() + (7 * 24 * 60 * 60);
4 // 7 Tage; 24 Stunden; 60 Minuten; 60 Sekunden
5echo 'Jetzt: '. date('Y-m-d') ."\n";
6echo 'Naechste Woche: '. date('Y-m-d', $nextWeek) ."\n";
7// oder strtotime() verwenden:
8echo 'Naechste Woche: '. date('Y-m-d', strtotime('+1 week')) ."\n";
9?>
10
11