Last active
September 12, 2016 18:42
-
-
Save ronaldooliveiradevbr/ded7a5a4bd183ff842732282e7e7900d to your computer and use it in GitHub Desktop.
Aí eu páro e penso: car****!!!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace sehLocoCachoeira; | |
class Inutils | |
{ | |
public static function dateToTimestamp($date) | |
{ | |
// Converte formato Date do PHP para Timestamp do SQL | |
$dateTimeDB = ""; | |
if (!empty($date)){ | |
$data1 = explode(" ", $date); | |
if (sizeof($data1) > 1){ | |
$arr_data1 = $data1[0]; | |
$arr_hora1 = $data1[1]; | |
$dt1 = explode("/",$arr_data1); | |
$hs1 = explode(":",$arr_hora1); | |
$dateTimeDB = $dt1[2]."-".$dt1[1]."-".$dt1[0]." ".$hs1[0].":".$hs1[1]; | |
} elseif (sizeof($data1) == 1) { | |
$dt1 = explode("/", $data1[0]); | |
$dateTimeDB = $dt1[2]."-".$dt1[1]."-".$dt1[0]." 00:00:00"; | |
} | |
} | |
return $dateTimeDB; | |
} | |
public static function getIp() | |
{ | |
if (isset($_SERVER["HTTP_X_FORWARDED_FOR"])) | |
return $_SERVER["HTTP_X_FORWARDED_FOR"]; | |
if (isset($_SERVER["REMOTE_ADDR"])) | |
return $_SERVER["REMOTE_ADDR"]; | |
if (isset($_SERVER["HTTP_CLIENT_IP"])) | |
return $_SERVER["HTTP_CLIENT_IP"]; | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment