Last active
January 14, 2024 02:19
-
-
Save IwonGunawan/2631773359340470be34e45d118cf113 to your computer and use it in GitHub Desktop.
PHP
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 | |
// 01 - 31 | |
function daily() | |
{ | |
$tday = "01"; | |
$tmonth = date("m"); | |
$tyear = date("Y"); | |
$date_from = "01"; | |
$date_to = date("d", strtotime('-1 second',strtotime('+1 month',strtotime($tmonth.'/'.$tday.'/'.$tyear.' 00:00:00')))); | |
} | |
// monday - sunday | |
function weekly() | |
{ | |
$monday = strtotime("last monday"); | |
$monday = date('w', $monday)==date('w') ? $monday+7*86400 : $monday; | |
$sunday = strtotime(date("Y-m-d",$monday)." +6 days"); | |
$date_from = date("Y-m-d",$monday); | |
$date_to = date("Y-m-d",$sunday); | |
} | |
// 2021-03-01 - 2021-03-31 | |
funtion monthly() | |
{ | |
$tday = "01"; | |
$tmonth = date("m"); | |
$tyear = date("Y"); | |
$date_from = date("Y-m-d", strtotime($tmonth.'/'.$tday.'/'.$tyear.' 00:00:00')); | |
$date_to = date("Y-m-d", strtotime('-1 second',strtotime('+1 month',strtotime($tmonth.'/'.$tday.'/'.$tyear.' 00:00:00')))); | |
} | |
?> |
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 | |
// test connection | |
try { | |
$this->db::connection()->getPdo(); | |
} catch (\Exception $e) { | |
die("Could not connect to the database. Please check your configuration. error:" . $e ); | |
} |
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 | |
// search multidiemensional | |
array_search('100', array_column($userdb, 'uid')); | |
// sum multidimensional | |
array_sum(array_column($account_invoices, 'vatAmount')); | |
// random number for 'member_code' | |
echo(rand(100000,999999)); | |
?> |
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 | |
echo(rand(100000,999999)); | |
echo "&&"; | |
echo gen_uuid(); | |
function gen_uuid() | |
{ | |
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', | |
// 32 bits for "time_low" | |
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), | |
// 16 bits for "time_mid" | |
mt_rand( 0, 0xffff ), | |
// 16 bits for "time_hi_and_version", | |
// four most significant bits holds version number 4 | |
mt_rand( 0, 0x0fff ) | 0x4000, | |
// 16 bits, 8 bits for "clk_seq_hi_res", | |
// 8 bits for "clk_seq_low", | |
// two most significant bits holds zero and one for variant DCE1.1 | |
mt_rand( 0, 0x3fff ) | 0x8000, | |
// 48 bits for "node" | |
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) | |
); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment