Pure native js copy2clipboard

snippets for copy text to clipboard

let input = document.createElement('input');
    document.body.appendChild(input);
    input.style.position = 'fixed';
    input.style.left = 0;
    input.style.right = 0;
    input.value = window.location.href;
    if (window.navigator.userAgent.match(/ipad|iphone|ipod/i)) {
        let range = window.document.createRange();
        let  selection = window.getSelection();
        range.selectNodeContents(input);
        selection.removeAllRanges();
        selection.addRange(range);
        input.readOnly = true;
        input.setSelectionRange(0, 999999);
        input.readOnly = false;
    } else {
        input.select();
    }
document.execCommand('copy');
input.remove();

Laravel Timezone setting

Add TIMEZONE to .env file

.env

TIMEZONE="Asia/Hong_Kong"

Modify the config/app.php to using the TIMEZONE env variable.

// "timezone" => "UTC",
"timezone" => env("TIMEZONE", "UTC"),  //replace

Modify config/database.php to using the TIMEZONE env variable.

'connections' => [
    'mysql' => [
        'driver' => 'mysql',
        //...
        'timezone' => today(env("TIMEZONE", "UTC"))->format("P"), // append this config
    ]
]