Skip to content

Instantly share code, notes, and snippets.

@CodeBrauer
Last active June 27, 2016 09:10
Show Gist options
  • Select an option

  • Save CodeBrauer/3d0e7e46d968bd03831d to your computer and use it in GitHub Desktop.

Select an option

Save CodeBrauer/3d0e7e46d968bd03831d to your computer and use it in GitHub Desktop.
some codecandies I just find sometimes...
<?php
// most complicated way to reformart a date... also deprecated function
ereg("([0-9]{4}).([0-9]{2}).([0-9]{2})", $value['check_in'], $alter);
$bdate="$alter[3].$alter[2].$alter[1]";
echo $bdate;
<?php
ini_set('display_errors', '1'); error_reporting(E_ALL);
session_start();
// [...]
// some requires and includes that could already sent some errors...
// [...]
$userName = $_SESSION['user'];
if(isset($userName)){ // check user is logged in (lol)
}else{
header('location:index.php');
}
<?php
// could be easier to get GMT Date with 2 hours added
echo gmdate('D, d M Y H:i:s', mktime(date("H")+2,date("i"),date("s"),date("m"),date("d"), date("Y"))) . " GMT";
// found in an codecanyon pure php application.
<?php
function konv_date($date){
$jahr = substr($date,0,4);
$mon = substr($date,5,2);
$tag = substr($date,8,2);
$datneu = $tag.'.'.$mon.'.'.$jahr;
return $datneu;
// return date('d.m.Y', strtotime($date)); would do the same... and would be safer ... and faster...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment