Top
Home

Time into Variable


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

According to Hour



Day



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

It is 04



<?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) | 15
D - A textual representation of a day (three letters) | Sat
j - The day of the month without leading zeros (1 to 31)| 15
l (lowercase 'L') - A full textual representation of a day | Saturday
N - The ISO-8601 numeric representation of a day (1 for Monday through 7 for Sunday) | 6
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) | 6
z - The day of the year (from 0 through 365) | 45

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

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

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

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

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

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

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

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

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) | 2025-02-15T04:33:56+00:00
r - The RFC 2822 formatted date (e.g. Thu, 21 Dec 2000 16:01:07 +0200) | Sat, 15 Feb 2025 04:33:56 +0000
U - The seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) | 1739594036