List

Try: ca/tecreations/ViewFile.php


<?php

global $now, $nowDT, $nowYMD, $nowHMS, $nowMicro;

$now = new Datetime('now'); //new DateTimeZone("UTC")); 
$nowDT = $now;
$offset = $now->format('Z') / 3600;
$nowAll = $offset . " -- " . $now->format('Z') . " -- " . $now->format('Y-m-d H:i:s.u');
$nowHMS = $now->format('Y-m-d H:i:s');
$nowMicro = $now->format('Y-m-d H:i:s.u');
$nowTime = $now->format('H:i:s');
$nowYMD = $now->format('Y-m-d');


global $DEBUG, $VERBOSE, $tec8_DaysOld;
if ($DEBUG && $VERBOSE) {
    print("Now: All: $" . "nowAll: $nowAll [{GMT Offset + Comparator}]<br />\n");
    print("Now: HMS: $" . "nowHMS: $nowHMS<br />\n");
    print("Now: micro: $" . "nowMicro: $nowMicro<br />\n");
    print("Now: Time: $" . "nowTime: $nowTime<br />\n");
    print("Now: UNIX: strtotime(\$" . "nowMicro): " . strtotime($nowMicro) . "<br />\n");
    print("Now: YMD: $" . "nowYMD: $nowYMD<br />\n");
    print("<hr />");
}

date_default_timezone_set('America/Edmonton');
//print_r(date_default_timezone_get()); print("<br />");

GLOBAL $albertaOffset;

$albertaOffset = date('Z') / 3600;

//print("Alberta Offset: $albertaOffset<br />");

//echo "Now: $nowWithHMS -- diff: (From index_SetAt): $millis : $hours<br>";
//echo "3 Oct, 2005: " . strtotime("3 October 2005") . "<br />";
//echo "5Hours from Now: " . strtotime("+5 hours") . "<br />";
//echo "1Week from Now: " . strtotime("+1 week") . "<br />";
//echo "1Month from Now: " . strtotime("+1 Month") . "<br />";

global $DEBUG, $VERBOSE;

if ($DEBUG && $VERBOSE) {
    print_r($now); print("<br />");
    print("NowYMD: $nowYMD<br />");
    print("NowWithHMS: $nowWithHMS<br />");
    print("DT: " . $nowMicro);
}

function getTimeAsDigits($str = "") {
    return strtotime(str);    
}

function getFormattedDateTime($ts = "") {
   return date("Y-m-d H:i:s",$ts);
}

function getFormattedHMS($ts = "") {
    return date("H:i:s",$ts);
}

function getFormattedYMD($ts = "") {
    return date("Y-m-d",$ts);
}

function getMicro($ts = "") {
    return date("Y-m-d H:i:s.u",$ts);
}

function getDaysBetween_DateTime($dt1 = "", $dt2 = "") {
    return (($dt1)->diff($dt2))->days;
}

function getDaysUntil_DateTime($dt1 = "", $dt2 = "") {
    return (($dt1)->diff($dt2))->days + 1;
}

function getDaysBetween_Timestamp($timestamp1 = "", $timestamp2 = "") {
    return (new DateTime($timestamp1))->diff(new DateTime($timestamp2))->days;
}

function getDaysInMonth_DT($DateTime = "") { 
    if ($DateTime == "") die("getDaysInMonth_DT() -- DateTime is empty");
    $month = $DateTime->format("m");
    return getDaysInMonth_String($month);
}

function getDaysInMonth_String($month = "") {
    if ($month == "") die("getDaysInMonth_int() -- month is empty");
    if ($month == "02") {
       if (isLeapYear($setAt->format("Y"))) $daysInMonth = 29;
       else $daysInMonth = 28;
    } else if ($month == "04") $daysInMonth = 30;
    else if ($month == "06") $daysInMonth = 30;
    else if ($month == "09") $daysInMonth = 30;
    else if ($month == "11") $daysInMonth = 30;
    else $daysInMonth = 31;
    return (int)$daysInMonth;
}

function getShortMonth() {
    $month = date("F");
    if ($month == "January") return "Jan";
    else if ($month == "February") return "Feb";
    else if ($month == "March") return "Mar";
    else if ($month == "April") return "Apr";
    else if ($month == "May") return "May";
    else if ($month == "June") return "Jun";
    else if ($month == "July") return "Jul";
    else if ($month == "August") return "Aug";
    else if ($month == "September") return "Sep";
    else if ($month == "October") return "Oct";
    else if ($month == "November") return "Nov";
    else if ($month == "December") return "Dec";
}

//https://www.geeksforgeeks.org/php-program-to-check-a-given-year-is-a-leap-year-or-not/
function isLeapYear($year) { 
    if (($year % 4 == 0 && $year % 100 != 0)  
        || ($year % 400 == 0)) { 
        return true; 
    } else { 
        return false; 
    } 
}