本文整理匯總了PHP中DateUtil::getCurrentTime方法的典型用法代碼示例。如果您正苦於以下問題:PHP DateUtil::getCurrentTime方法的具體用法?PHP DateUtil::getCurrentTime怎麽用?PHP DateUtil::getCurrentTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DateUtil
的用法示例。
在下文中一共展示了DateUtil::getCurrentTime方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: synchronizedUserInfo
/**
* 將用戶信息同步到數據庫
*/
public function synchronizedUserInfo($userInfo, $Event)
{
global $db;
$openid = $userInfo["openid"];
$subscribe = $userInfo["subscribe"];
$currtime = DateUtil::getCurrentTime();
$sql = "";
if ($Event == "subscribe") {
LogUtil::logs("TypeEvent synchronizedUserInfo insert=====> ", getLogFile("/business.log"));
$nickname = $userInfo["nickname"];
$nickname = base64_encode($nickname);
//$nickname = str_replace("🌻", "*", $nickname);
$sex = $userInfo["sex"];
$headimgurl = $userInfo["headimgurl"];
$sql = $sql . ", nickname='{$nickname}', sex='{$sex}'";
LogUtil::logs("TypeEvent.php synchronizedUserInfo :nickname ====>" . $nickname, getLogFile('/business.log'));
// 關注的情況有關注和重新關注,所以使用on duplicate的方法
$sql = "INSERT INTO `wx_user_info` (openid, nickname, sex, subscribe, subscribe_time, headimgurl) \r\n\t\t\tVALUES ('{$openid}', '{$nickname}', '{$sex}', '{$subscribe}', '{$currtime}', '{$headimgurl}') \r\n\t\t\tON DUPLICATE KEY UPDATE subscribe='{$subscribe}', nickname='{$nickname}', subscribe_time='{$currtime}', headimgurl='{$headimgurl}'";
} else {
// 取消關注
LogUtil::logs("TypeEvent synchronizedUserInfo update=====> ", getLogFile("/business.log"));
$sql = "update `wx_user_info` set subscribe_time='{$currtime}', subscribe='{$subscribe}' where openid = '{$openid}' ";
}
$db->exec($sql);
}
示例2: initWxTokenToDB
/**
* save token to db
*/
public static function initWxTokenToDB()
{
global $db;
$url = wxTokenUrl() . "&appid=" . appid() . "&secret=" . secret();
// 請求微信token
//LogUtil::logs("initWxTokenToDB tokenurl====>".$url, getLogFile('/business.log'));
$arr = RequestUtil::httpGet($url);
$newToken = $arr['access_token'];
//LogUtil::logs("initWxTokenToDB newToken====>".$newToken, getLogFile('/business.log'));
// 請求微信ticket
$newTicket = self::initTicket($newToken);
$updatetime = DateUtil::getCurrentTime();
// 加鎖文件
if (file_exists($lockfile)) {
//LogUtil::logs("initWxTokenToDB ====> file in writing, only can read\r\n", getLogFile('/business.log'));
exit;
}
// save or update;
$db->exec("INSERT INTO wx_token(id, token, updatetime, ticket) \r\n\t\tvalues(1, '{$newToken}','{$updatetime}','{$newTicket}') \r\n\t\tON DUPLICATE KEY UPDATE token='{$newToken}', updatetime='{$updatetime}', ticket='{$newTicket}'");
// 關閉鎖文件
fclose($lockTemp);
// 刪除鎖文件
unlink($lockfile);
return $newToken;
}
示例3: addone
function addone()
{
// $_SESSION['cn_sysadmin']['user_id'] = $user_id;
// $_SESSION['cn_sysadmin']['role_name'] = $role['name'];
// $_SESSION['cn_sysadmin']['role_id'] = $role['id'];
global $db;
$createby = $_SESSION['cn_sysadmin']['user_id'];
$createtime = DateUtil::getCurrentTime();
$groupname = empty($_POST["groupname"]) ? '' : $_POST["groupname"];
if ($groupname != "") {
$backup = empty($_POST["backup"]) ? '' : $_POST["backup"];
$sql = "insert into wx_group_info (createby, createtime, groupname, backup) values ('{$createby}', '{$createtime}', '{$groupname}', '{$backup}')";
$db->exec($sql);
}
// 添加後,重新再查一遍
showlist();
}
示例4: reply
function reply()
{
// msgid 是回複的目標消息id 對應表 的 replyid
$msgid = $_POST["msgid"];
if (empty($msgid)) {
return;
}
$content = $_POST["content"];
if (empty($content)) {
return;
}
$openid = $_POST["createby"];
if (empty($openid)) {
return;
}
// 回複消息要做2件事
// 1 調微信接口
$paramContent = array();
$contentTemp = array("content" => "管理員回複:\r\n" . $content);
$paramContent = array("msgtype" => "text", "text" => $contentTemp);
$data = JsonUtil::getJsonStrFromArray(array_merge($paramContent, array("touser" => $openid)));
//LogUtil::logs("queryGroupUserAndReplyMsg data ====>".$data, getLogFile("/business.log"));
$tp = new TypeParent();
$response = $tp->sendMsgByService($data);
if ($response["errcode"] == 0) {
// 回複成功
// 2 保存回複的消息
$msgtype = "1";
// 消息類型: 0表示用戶發送 1表示管理員回複 2表示管理員群發消息 3 自動回複 4聊天室信息
$status = "0";
// 消息狀態 :0: 消息發送成功 1: 發送中 2 發送失敗, 保存成功 3 發送成功, 保存失敗 4 表示這條信息是用戶送的,並且已經得到回複
$createtime = DateUtil::getCurrentTime();
$createby = $_SESSION['cn_sysadmin']['user_id'];
// 消息類型: 0表示用戶發送 1表示管理員回複 2表示管理員群發消息 3 自動回複 4聊天室信息
DBUtil::saveMsg($createby, $content, $createtime, $msgid, $msgtype, $status);
// 原來設計是將狀態改為4用來標識已回複,現在能查到回複內容,就取消這個方案了
// $sql = "update wx_user_msg set status = '4' where id ='$msgid'";
// DBUtil::updateMsg($sql);
}
showlist();
}
示例5: queryGroupUserAndReplyMsg
/**
* 查到用戶組裏麵的所有組員,再向其發送消息
*/
function queryGroupUserAndReplyMsg($userGroupId, $postData)
{
global $db;
// 發消息的人自己
$userSelfOpenid = $postData["FromUserName"];
$content = $postData["Content"];
$createtime = DateUtil::getCurrentTime();
$mediaid = $postData["MediaId"];
// 用戶發送的信息,要保存到數據庫
// 消息類型: 0表示用戶發送 1表示管理員回複 2表示管理員群發消息 3 自動回複 4聊天室信息
DBUtil::saveMsg($userSelfOpenid, "圖片消息", $createtime, "", "4", "0");
// 查詢所有的組員
$arr = array();
// TODO 這個$res可以緩存到文件中
$res = $db->query("SELECT * FROM wx_group_user where groupid = '{$userGroupId}' and userisin = '0' ");
$row = $db->fetch_all($res);
foreach ($row as $val) {
// 循環每個人推送一條消息
$openid = $val['openid'];
// 從組中除去發信息者自己
if ($userSelfOpenid != $openid) {
// 拚接
/*{
"touser":"OPENID",
"msgtype":"image",
"image":
{
"media_id":"MEDIA_ID"
}
}*/
$paramContent = array("touser" => $openid, "msgtype" => "image", "image" => array("media_id" => $mediaid));
$data = JsonUtil::getJsonStrFromArray($paramContent);
LogUtil::logs("queryGroupUserAndReplyMsg data ====>" . $data, getLogFile("/business.log"));
parent::sendMsgByService($data);
}
}
return getSuccessStr();
}
示例6: transactionSave
function transactionSave($user_info_list)
{
$errorOpenids = "";
$successcount = 0;
$failcount = 0;
LogUtil::logs("要保存到數據庫的用戶信息數量====> " . count($user_info_list), getLogFile("/business.log"));
//echo print_r($user_info_list);
global $db;
if (!empty($user_info_list)) {
mysql_query('START TRANSACTION');
foreach ($user_info_list as $userinfo) {
/*if(($successcount + $failcount) % 5000 == 0) {
mysql_query('START TRANSACTION');
}*/
$openid = $userinfo["openid"];
if (!empty($openid)) {
//echo print_r($userinfo);
$nickname = base64_encode($userinfo["nickname"]);
//$nickname = $userinfo["nickname"];
// 默認是/0 表示640*640的尺寸 有0、46、64、96、132
$headimgurl = $userinfo["headimgurl"];
$sex = $userinfo["sex"];
$subscribe = $userinfo["subscribe"];
$currtime = DateUtil::getCurrentTime();
$sql = "INSERT INTO `wx_user_info` (openid, nickname, sex, subscribe, subscribe_time, headimgurl) \r\n\t\t\t\t\tVALUES ('{$openid}', '{$nickname}', '{$sex}', '{$subscribe}', '{$currtime}', '{$headimgurl}')";
$execres = $db->exec($sql);
if (!$execres) {
$errorOpenids .= $openid . "; ";
$failcount = $failcount + 1;
} else {
$successcount = $successcount + 1;
}
}
/*if(($successcount + $failcount) % 5000 == 0) {
mysql_query('COMMIT');
}*/
}
// mysql_query('ROLLBACK ');
mysql_query('COMMIT');
if (!empty($errorOpenids)) {
LogUtil::logs("====>同步錯誤用戶名單:" . $errorOpenids, getLogFile("/db.log"));
}
LogUtil::logs("事務提交:成功" . $successcount . "條,失敗" . $failcount . "條", getLogFile("/business.log"));
}
}
示例7: autoReplay
/**
* 普通消息公共調用
* MsgType : text image voice video 等
*/
function autoReplay($postData)
{
$openid = $postData["FromUserName"];
$content = $postData["Content"];
$createtime = DateUtil::getCurrentTime();
$msgData = array();
if ($postData['MsgType'] == 'text' && !empty($content)) {
// 判斷是否修改信息
// $strrule = "/^更新信息+.*/";
$strrule = "/^備注#.*/";
LogUtil::logs("autoReplay content ====>" . $content, getLogFile("/business.log"));
if (preg_match($strrule, $content)) {
LogUtil::logs("autoReplay content ====>" . $content, getLogFile("/business.log"));
//$arr = explode("+", $content);
$arr = explode("#", $content);
$returnmsg = "";
$backup = $arr[1];
if (!preg_match("/^.{0,30}\$/", $backup)) {
$returnmsg .= " 親備注信息不要超過30個字符哦/:,@-D";
$paramsData['Content'] = $returnmsg;
$paramsData['MsgType'] = 'text';
return parent::packageData($postData, $paramsData);
}
/*$mobile = $arr[2];
if(!preg_match("/^1[3|4|5|7|8][0-9]\\d{8}$/", $mobile)){
$returnmsg .= " 手機號格式不正確";
}*/
if (empty($returnmsg)) {
$returnmsg = "信息更新申請成功";
}
global $db;
//$db -> exec("update wx_user_info set localnickname='$localnickname', mobile='$mobile' where openid='$openid'");
$db->exec("update wx_user_info set backup='{$backup}', mobile='{$mobile}' where openid='{$openid}'");
// 用戶申請更新信息
$paramsData['Content'] = $returnmsg;
$paramsData['MsgType'] = 'text';
return parent::packageData($postData, $paramsData);
} else {
// 不更新信息的情況下,隻要保存到後台即可
DBUtil::saveMsg($openid, $content, $createtime, "", "5", "0");
return getSuccessStr();
}
// 用戶發送的信息,要保存到數據庫// 消息類型: 0表示用戶發送 1表示管理員回複 2表示管理員群發消息 3 自動回複 4聊天室信息 5用戶私聊管理員
}
}