. * * index.php * * PHP-Classic-ASP-polyfills index file. * * @author Daniele Bonini * @copyrights (c) 2021, 2024, 5 Mode */ define("FUNCTIONS_PATH", __DIR__.DIRECTORY_SEPARATOR."functions"); // CLASSIC ASP POLYFILLS require FUNCTIONS_PATH . DIRECTORY_SEPARATOR . "/func.casp-datetime-polyfills.inc"; require FUNCTIONS_PATH . DIRECTORY_SEPARATOR . "/func.casp-string-polyfills.inc"; ?>
  // left() example
  $s = "Reputation is everything. Almost everything..";
  echo(left($s,10)."<br>");
Result:

"); ?>
  // right() example
  $s = "Reputation is everything. Almost everything..";
  echo(right($s,19)."<br>");
Result:

"); ?>
  // space() example
  $s = "Reputation is everything. Almost everything..";
  echo(left($s,10).space(5).right($s,35)."<br>");
Result:

"); ?>
  // id_date() example #1
  $s = "Reputation is everything. Almost everything..";
  echo((is_date($s)?"true":"false")."<br>");
Result:

"); ?>
  // id_date() example #2
  $s = "27/09/2021";
  echo((is_date($s)?"true":"false")."<br>");
Result:

"); ?>
  // year() example #1
  $v = "27/09/2021";
  echo(year($v)."<br>");
Result:

"); ?>
  // year() example #2
  $v = new DateTime("09/27/2021");
  echo(year($v)."<br>");
Result:

"); ?>
  // year() example #3
  echo(year()."<br>");
Result:

"); ?>
  // month() example
  $v = new DateTime("09/27/2021");
  echo(month($v)."<br>");
Result:

"); ?>
  // day() example
  $v = new DateTime("09/27/2021");
  echo(day($v)."<br>");
Result:

"); ?>
  // hour() example
  $v = new DateTime("09/27/2021 22:05:55");
  echo(hour($v)."<br>");
Result:

"); ?>
  // minute() example
  $v = new DateTime("09/27/2021 22:05:55");
  echo(minute($v)."<br>");
Result:

"); ?>
  // second() example
  $v = new DateTime("09/27/2021 22:05:55");
  echo(second($v)."<br>");
Result:

"); ?>
  // monthName() example
  $v = new DateTime("09/27/2021 22:05:55");
  echo(monthName($v)."<br>");
Result:

"); ?>
  // weekday() example
  $v = new DateTime("09/27/2021 22:05:55");
  echo(weekday($v)."<br>");
Result:

"); ?>
  // now() example
  echo(now()."<br>");
Result:

"); ?>
  // date_add1() example #1
  $d1 = new DateTime("09/27/2021 22:05:55");
  $d1 = date_add1("Y", 1, $d1);
  echo($d1->format("Y/d/m H:i:s A")."<br>");
Result:
format("Y/d/m H:i:s A")."

"); ?>
  // date_add1() example #2
  $d1 = new DateTime("09/27/2021 22:05:55");
  $d1 = date_add1("d", -5, $d1);
  echo($d1->format("Y/d/m H:i:s A")."<br>");
Result:
format("Y/d/m H:i:s A")."

"); ?>