Skip to content

Instantly share code, notes, and snippets.

View dolphin836's full-sized avatar
💭
Finding

海兵大侠 dolphin836

💭
Finding
View GitHub Profile
@dolphin836
dolphin836 / strtotime.php
Last active June 6, 2017 08:58
[获取今天、本周、本月、今年的开始和结束的UNIX时间戳] #tags:UNIX,时间戳
// 今天
$start = strtotime("today");
$end = $start + 3600 * 24;
// 本周
$start = mktime(0, 0 , 0, date("m"), date("d") - date("w") + 1, date("Y"));
$end = mktime(23, 59, 59, date("m"), date("d") - date("w") + 7, date("Y"));
// 本月
$start = mktime(0, 0 , 0, date("m"), 1, date("Y"));
$end = mktime(23, 59, 59, date("m"), date("t"), date("Y"));
// 今年
@dolphin836
dolphin836 / rsa2.php
Created May 24, 2017 02:54
[PHP RSA2 签名算法] #tags:签名,RSA2,算法
class Rsa2
{
private static $PRIVATE_KEY = 'rsa_private_key.pem';
private static $PUBLIC_KEY = 'rsa_public_key.pem';
/**
* 获取私钥
* @return bool|resource
*/
private static function getPrivateKey()
@dolphin836
dolphin836 / sign.php
Created May 18, 2017 06:43
[微信签名算法] #tags:微信,算法,签名
/*
* @param array $data 需要签名的数据
* @param string $key 账户的 KEY
*
* @return string 签名字符串
*/
function sign($data = array(), $key)
{
ksort($data);
@dolphin836
dolphin836 / user_agent.js
Created May 17, 2017 06:57
[通过 User Agent 识别微信和支付宝内置浏览器] #tags:微信,支付宝,浏览器
function is_weixin()
{
var ua = navigator.userAgent.toLowerCase();
if(ua.match(/MicroMessenger/i) == "micromessenger")
{
return true;
}
else
{