Top
Home

Time into Variable


$todae=date ("Y/m/d-G:i");

According to Hour



Night



<?php
if (date("H")<19)
{echo "Day";}
else
{echo "Night";}
?>

It is 20



<?php
$a = (date("H"));
switch($a)
{
case "01":
       print("It is 01");
       break;
case "02":
       print("It is 02");
       break;
case "03":
       print("It is 03");
       break;
case "04":
       print("It is 04");
       break;
case "05":
       print("It is 05");
       break;
case "06":
       print("It is 06");
       break;
case "07":
       print("It is 07");
       break;
case "08":
       print("It is 08");
       break;
case "09":
       print("It is 09");
       break;
case "10":
       print("It is 10");
       break;
case "11":
       print("It is 11");
       break;
case "12":
       print("It is 12");
       break;
case "13":
       print("It is 13");
       break;
case "14":
       print("It is 14");
       break;
case "15":
       print("It is 15");
       break;
case "16":
       print("It is 16");
       break;
case "17":
       print("It is 17");
       break;
case "18":
       print("It is 18");
       break;
case "19":
       print("It is 19");
       break;
case "20":
       print("It is 20");
       break;
case "21":
       print("It is 21");
       break;
case "22":
       print("It is 22");
       break;
case "23":
       print("It is 23");
       break;
case "24":
       print("It is 24");
       break;
default:
       print("I don't Know What Time It Is");
       break;
}
?>

Convert Timezone


<?php
$todae=date ("G:i");
$date = new DateTime($todae, new DateTimeZone('America/Chicago'));
date_default_timezone_set('America/New_York');
$todae=date("G:i", $date->format('U'));
?>

DAY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

d - The day of the month (from 01 to 31) | 18
D - A textual representation of a day (three letters) | Mon
j - The day of the month without leading zeros (1 to 31)| 18
l (lowercase 'L') - A full textual representation of a day | Monday
N - The ISO-8601 numeric representation of a day (1 for Monday through 7 for Sunday) | 1
S - The English ordinal suffix for the day of the month (2 characters st, nd, rd or th. Works well with j) | th
w - A numeric representation of the day (0 for Sunday through 6 for Saturday) | 1
z - The day of the year (from 0 through 365) | 351

WEEK %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

W - The ISO-8601 week number of year (weeks starting on Monday) | 51

MONTH %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

F - A full textual representation of a month (January through December) | December
m - A numeric representation of a month (from 01 to 12) | 12
M - A short textual representation of a month (three letters) | Dec
n - A numeric representation of a month, without leading zeros (1 to 12) | 12
t - The number of days in the given month | 31

YEAR %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

L - Whether it's a leap year (1 if it is a leap year, 0 otherwise) | 0
o - The ISO-8601 year number | 2017
Y - A four digit representation of a year | 2017
y - A two digit representation of a year | 17

TIME %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

a - Lowercase am or pm | pm
A - Uppercase AM or PM | PM
B - Swatch Internet time (000 to 999) | 889
g - 12-hour format of an hour (1 to 12) | 8
G - 24-hour format of an hour (0 to 23) | 20
h - 12-hour format of an hour (01 to 12) | 08
H - 24-hour format of an hour (00 to 23) | 20
i - Minutes with leading zeros (00 to 59) | 20
s - Seconds, with leading zeros (00 to 59) | 45

Etc %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

e - The timezone identifier (Examples: UTC, Atlantic/Azores) | UTC
I (capital i) - Whether the date is in daylights savings time (1 if Daylight Savings Time, 0 otherwise) | 0
O - Difference to Greenwich time (GMT) in hours (Example: +0100) | +0000
T - Timezone setting of the PHP machine (Examples: EST, MDT) | UTC
Z - Timezone offset in seconds. The offset west of UTC is negative, and the offset east of UTC is positive (-43200 to 43200) | 0
c - The ISO-8601 date (e.g. 2004-02-12T15:19:21+00:00) | 2017-12-18T20:20:45+00:00
r - The RFC 2822 formatted date (e.g. Thu, 21 Dec 2000 16:01:07 +0200) | Mon, 18 Dec 2017 20:20:45 +0000
U - The seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) | 1513628445