本文整理汇总了PHP中DateTime函数的典型用法代码示例。如果您正苦于以下问题:PHP DateTime函数的具体用法?PHP DateTime怎么用?PHP DateTime使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DateTime函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
/**
* Set
* @param string $name
* @param mixed $value
* @param int $expiry
* @param sting $path
* @param string $domain
* @param bool $httponly
* @return BOOL
*/
public static function set($name, $value, $expiry = self::ONE_YEAR, $path = '/', $domain = null, $httponly = false)
{
if (headers_sent() || empty($name)) {
return false;
}
if (empty($value)) {
$expiry = -1;
} else {
if (is_numeric($expiry)) {
$expiry += time();
} else {
$expiry = \DateTime($expiry);
}
}
if (empty($domain) && isset($_SERVER['SERVER_NAME']) && strcasecmp($_SERVER['SERVER_NAME'], 'localhost') !== 0) {
if (filter_var($host = parse_url(SITE_URL, PHP_URL_HOST), FILTER_VALIDATE_IP) !== false) {
$domain = $host;
} else {
$domain = '.' . preg_replace('#^www\\.#', '', $host);
}
}
$secure = defined("SITE_PROTOCOL") && SITE_PROTOCOL == 'https://';
if (setcookie($name, $value, $expiry, $path, $domain, $secure, $httponly)) {
$_COOKIE[$name] = $value;
return true;
}
return false;
}
示例2: indexAction
public function indexAction($name)
{
$datetime = \DateTime();
$em = $this->getDoctrine()->getManager();
$em->persist($object);
$em->flush();
return $this->render('InfoDemoBundle:Default:index.html.twig', array('name' => $name));
}
示例3: createAction
/**
* Creates a new Pasaporte entity.
*
* @Route("/", name="pasaporte_create")
* @Method("POST")
* @Template("AppBundle:Pasaporte:new.html.twig")
*/
public function createAction(Request $request)
{
$entity = new Pasaporte();
$form = $this->createCreateForm($entity);
$form->handleRequest($request);
if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$entity->setFechaDesde(\DateTime($entity->getFechaDesde));
$entity->setFechaHasta(\DateTime($entity->getFechaHasta));
$em->persist($entity);
$em->flush();
return $this->redirect($this->generateUrl('pasaporte_show', array('id' => $entity->getId())));
}
return array('entity' => $entity, 'form' => $form->createView());
}
示例4: DateTime
<label class="col-md-2 control-label"><?php
echo $smarty->get_template_vars('LBL_INVOICE_PAYABLE_DATE');
?>
</label>
<div class="col-md-4">
<?php
echo $dtls[0]['dNetPaymentdate'] != '0000-00-00' ? DateTime(calcLTzTime($dtls[0]['NetPaymentdate']), 10) : '---';
?>
</div>
<label class="col-md-2 control-label"><?php
echo $smarty->get_template_vars('LBL_ACCEPTED') . ' ' . $smarty->get_template_vars('LBL_DATE');
?>
</label>
<div class="col-md-4">
<?php
echo $dtls[0]['dAcceptedDate'] != '0000-00-00' ? DateTime(calcLTzTime($dtls[0]['dAcceptedNetPaymentDate']), 10) : '---';
?>
</div>
<label class="col-md-2 control-label"><?php
echo $smarty->get_template_vars('LBL_INVOICE_PAYABLE') . ' (' . $smarty->get_template_vars('LBL_ACCEPTED') . ') ' . $smarty->get_template_vars('LBL_AMOUNT');
?>
</label>
<div class="col-md-4">
<?php
echo $dtls[0]['fAcceptedAmount'];
?>
</div>
<label class="col-md-2 control-label"> <?php
echo $smarty->get_template_vars('LBL_INVOICE_TOTAL');
?>
</label>
示例5: setCreatedAt
function setCreatedAt()
{
$this->createdAt = \DateTime('now', new \DateTimeZone('America/Sao_Paulo'));
return $this;
}
示例6: getVerificationMessage
function getVerificationMessage($iOrgId, $dtls)
{
global $smarty;
$msg = "";
$userid = $_SESSION['SESS_' . PRJ_CONST_PREFIX . '_ID'];
$usertype = $_SESSION['SESS_' . PRJ_CONST_PREFIX . '_USER_TYPE_SHORT'];
$orgid = $_SESSION['SESS_' . PRJ_CONST_PREFIX . '_ORGID'];
if ($dtls[0]['eStatus'] == "Need to Verify") {
if ($dtls[0]['iASMID'] == $userid) {
$msg = $smarty->get_template_vars('MSG_OTHER_VERIFICATION_NEED');
} else {
$sql = "Select CONCAT(vFirstName,' ',vLastName) as name from " . PRJ_DB_PREFIX . "_security_manager where iSMID=" . $dtls[0]['iASMID'];
$musr = $this->_obj->MySqlSelect($sql);
$msg = $smarty->get_template_vars('LBL_REC_CREATE_BY') . " " . $musr[0]['name'] . " " . $smarty->get_template_vars('LBL_ON') . " " . DateTime($dtls[0]['dCreatedDate'], '0');
}
} else {
if ($dtls[0]['eStatus'] == "Modified" || $dtls[0]['eStatus'] == "Delete" || $dtls[0]['eNeedToVerify'] == "Yes") {
if ($dtls[0]['eModifiedBy'] == $usertype && $dtls[0]['iModifiedByID'] == $userid) {
$msg = $smarty->get_template_vars('MSG_OTHER_VERIFICATION_NEED');
} else {
$msg = $smarty->get_template_vars('LBL_REC_MODIFIED_BY') . " " . $dtls[0]['iModifiedByID'] . " " . $smarty->get_template_vars('LBL_ON') . " " . DateTime($dtls[0]['dModifiedDate'], '0');
}
}
}
return $msg;
}
示例7: mysql_query
echo $titler[13];
?>
/webboard/img/userinfo.gif" width="16" height="16" /> โดย
<?php
$snickname = "SELECT name FROM `member` WHERE id='{$objResult['2']}'";
$renickname = mysql_query($snickname) or die("Error {$snickname}");
$rnickname = mysql_fetch_row($renickname);
echo $rnickname[0];
?>
<img src="http://<?php
echo $titler[13];
?>
/webboard/img/calendar-icon.png" width="16" height="16" /> เมื่อ
<?php
$postDate = $objResult[5];
echo DateTime($postDate);
?>
<img src="http://<?php
echo $titler[13];
?>
/webboard/img/ip.gif" width="15" height="14" />
<?php
echo $objResult[6];
?>
<?php
if ($_SESSION[m_id] == $objResult[2]) {
?>
<a href="http://<?php
echo $titler[13];
?>
/webboard/edit-webboard-reply.php?id=<?php
示例8: is_array
<p>
<span style="display:inline-block; width:359px;"><b style="font-size:12.9px;"><?php
echo $this->_tpl_vars['LBL_AWARD_NO'];
?>
:</b> <a href="<?php
echo $this->_tpl_vars['SITE_URL_DUM'];
?>
b2rfq2awardview/<?php
echo $this->_tpl_vars['latestaward'][$this->_sections['l']['index']]['iAwardId'];
?>
"><b style="font-size:12.9px;"><?php
echo $this->_tpl_vars['latestaward'][$this->_sections['l']['index']]['vAwardNum'];
?>
</b></a></span>
<span><?php
echo is_array($_tmp = is_array($_tmp = $this->_tpl_vars['latestaward'][$this->_sections['l']['index']]['dADate']) ? $this->_run_mod_handler('calcLTzTime', true, $_tmp) : calcLTzTime($_tmp)) ? $this->_run_mod_handler('DateTime', true, $_tmp, 10) : DateTime($_tmp, 10);
?>
</span><br>
<label><?php
echo $this->_tpl_vars['LBL_RFQ2_CODE'];
?>
:</label> <?php
echo $this->_tpl_vars['latestaward'][$this->_sections['l']['index']]['vRFQ2Code'];
?>
<br>
<label><?php
echo $this->_tpl_vars['LBL_BUYER2'];
?>
:</label> <?php
echo $this->_tpl_vars['latestaward'][$this->_sections['l']['index']]['vCompanyName'];
?>
示例9: DateTime
</strong>
</td>
<td width="25%" height="22" align="right" class="td-bg" valign="top">Created from IP</td>
<td width="25%" class="white-bg">
<strong><?php
echo $arr[0]['vFromIP'];
?>
</strong>
</td>
</tr>
<tr>
<td width="25%" height="22" align="right" class="td-bg">Last access date/time</td>
<td width="25%" class="white-bg">
<strong> <?php
if ($arr[0]['dLastAccess'] != '') {
$lastaccess = DateTime($arr[0]['dLastAccess'], "2");
} else {
$lastaccess = "---";
}
echo $lastaccess;
?>
</strong>
</td>
<td width="25%" height="22" align="right" class="td-bg">Total login</td>
<td width="25%" class="white-bg">
<strong><?php
echo $arr[0]['iTotLogin'];
?>
</strong>
</td>
</tr>
示例10: DateTime
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="gradient-strip"><img src="<?php
echo ADMIN_IMAGES;
?>
square-bullet.gif" align="absmiddle" border="0" alt="" />Last login </td>
</tr>
<tr>
<td class="inner-border">
<table width="100%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td width="24%">Last login</td>
<td width="1%">:</td>
<td width="75%"><strong>
<?php
echo DateTime($last_log[0]['dLoginDate'], "7");
?>
</strong></td>
</tr>
<tr>
<td>IP address</td>
<td>:</td>
<td><strong>
<?php
echo $last_log[0]['vIP'];
?>
</strong></td>
</tr>
</table>
</td>
</tr>
示例11: is_array
echo $this->_tpl_vars['LBL_ASSOCIATION'];
?>
</h3>
<p>
<?php
echo $this->_tpl_vars['LBL_BUYER2'];
?>
:<span> <?php
echo $this->_tpl_vars['b2sps_dtls'][0]['vBuyer2'];
?>
</span>
<?php
echo $this->_tpl_vars['LBL_DATE'];
?>
:<span> <?php
echo is_array($_tmp = is_array($_tmp = $this->_tpl_vars['b2sps_dtls'][0]['dADate']) ? $this->_run_mod_handler('calcLTzTime', true, $_tmp) : calcLTzTime($_tmp)) ? $this->_run_mod_handler('DateTime', true, $_tmp, 10) : DateTime($_tmp, 10);
?>
</span><br/>
<?php
echo $this->_tpl_vars['LBL_BPRODUCT'];
?>
: <span><?php
echo $this->_tpl_vars['b2sps_dtls'][0]['vSupplier'];
?>
</span><br />
<?php
echo $this->_tpl_vars['LBL_CODE'];
?>
: <span><a href="<?php
echo $this->_tpl_vars['SITE_URL_DUM'];
?>
示例12: DateTime
<?php
} else {
?>
<?php
echo $AlldataFile[$x];
?>
<?php
}
}
?>
</td>
<td width="20%" align="center" ><?php
echo DateTime(filemtime($path . $AlldataFile[$x]), '3');
?>
</td>
<td width="14%" align="left">
<?php
if (is_dir($path . $AlldataFile[$x])) {
$size = nicesize(getUserDirectorySize($path . $AlldataFile[$x]));
} else {
$size = nicesize(filesize($path . $AlldataFile[$x]));
}
$size = explode(" ", $size);
?>
<table border="0" width="100%">
<tr>
<td align="right" width="30%"><?php
echo $size[0];
示例13: is_array
echo $this->_tpl_vars['SITE_URL_DUM'];
?>
associationview/<?php
echo $this->_tpl_vars['activeassocs'][$this->_sections['j']['index']]['iAsociationID'];
?>
"><?php
echo $this->_tpl_vars['activeassocs'][$this->_sections['j']['index']]['vBuyerOrg'];
?>
</a></h3>
<p>
Buyer Organization Code:<span> <?php
echo $this->_tpl_vars['activeassocs'][$this->_sections['j']['index']]['vBuyerCode'];
?>
</span>
Date :<span> <?php
echo is_array($_tmp = is_array($_tmp = $this->_tpl_vars['activeassocs'][$this->_sections['j']['index']]['dCreatedDate']) ? $this->_run_mod_handler('calcLTzTime', true, $_tmp) : calcLTzTime($_tmp)) ? $this->_run_mod_handler('DateTime', true, $_tmp, 10) : DateTime($_tmp, 10);
?>
</span><br/>
<?php
if ($this->_tpl_vars['activeassocs'][$this->_sections['j']['index']]['eStatus'] != 'Need to Verify' && $this->_tpl_vars['activeassocs'][$this->_sections['j']['index']]['eStatus'] != 'Modified') {
?>
<?php
if ($this->_tpl_vars['activeassocs'][$this->_sections['j']['index']]['vVerifiedBy'] != '') {
?>
Verified By :<span> <?php
echo $this->_tpl_vars['activeassocs'][$this->_sections['j']['index']]['vVerifiedBy'];
?>
</span><?php
}
?>
<?php
示例14: Date
<script type="text/javascript" src="<?php
echo S_JQUERY;
?>
jquery.js" ></script>
<!--{*<script type="text/javascript" src="<?php
echo S_JQUERY;
?>
jquery_plugins.js" async="async"></script>*}-->
<script type="text/javascript" src="<?php
echo A_G_JS;
?>
jgeneral.js"></script>
<script type="text/javascript">
var clockLocalStartTime = new Date();
var clockServerStartTime = new Date(<?php
echo DateTime(time(), '4');
?>
);
</script>
<script type="text/javascript">
var SITE_URL = '<?php
echo SITE_URL;
?>
';
var SITE_URL_DUM = '<?php
echo SITE_URL_DUM;
?>
';
var ADMIN_URL = '<?php
echo ADMIN_URL;
?>
示例15: getHistory
function getHistory($vAsocCode)
{
global $smarty;
//$sql = "Select GROUP_CONCAT(astv.eStatus) as sts, GROUP_CONCAT(astv.iVerifiedSMID) as verifyid, GROUP_CONCAT(astv.eVerifiedBy) as verifyby, GROUP_CONCAT(astv.dVerifiedDate) as verifydate, GROUP_CONCAT(astv.iRejectedById) as rejectid, GROUP_CONCAT(astv.eRejectedBy) as rejectby, GROUP_CONCAT(astv.dRejectedDate) as rejectdate, astv.* from ".PRJ_DB_PREFIX."_organization_association_toverify astv where astv.vAssociationCode='$vAsocCode' Group By astv.iChangeNo ORDER BY astv.iChangeNo, astv.iVerifiedID ASC ";
// $sql = "Select GROUP_CONCAT(astv.eStatus) as sts, GROUP_CONCAT(astv.iModifiedByID) as modifyid, GROUP_CONCAT(astv.eModifiedBy) as modifyby, GROUP_CONCAT(astv.iVerifiedSMID) as verifyid, GROUP_CONCAT(astv.eVerifiedBy) as verifyby, GROUP_CONCAT(astv.dVerifiedDate) as verifydate, GROUP_CONCAT(astv.iRejectedById) as rejectid, GROUP_CONCAT(astv.eRejectedBy) as rejectby, GROUP_CONCAT(astv.dRejectedDate) as rejectdate, astv.* from ".PRJ_DB_PREFIX."_organization_association_toverify astv where astv.vAssociationCode='$vAsocCode' Group By astv.iChangeNo ORDER BY astv.iChangeNo, astv.iVerifiedID ASC ";
$sql = "Select astv.eStatus as sts, astv.iModifiedByID as modifyid, astv.eModifiedBy as modifyby, astv.iVerifiedSMID as verifyid, astv.eVerifiedBy as verifyby, astv.dVerifiedDate as verifydate, astv.iRejectedById as rejectid, astv.eRejectedBy as rejectby, astv.dRejectedDate as rejectdate, astv.* from " . PRJ_DB_PREFIX . "_organization_association_toverify astv where astv.vAssociationCode='{$vAsocCode}' ORDER BY astv.iChangeNo, astv.iVerifiedID ASC ";
//echo $sql; exit;
$vdtls = $this->_obj->MySQLSelect($sql);
// prints($vdtls); exit;
// for($ln=0;count($vdtls);$l++) {
for ($l = 0; $l < count($vdtls); $l++) {
if ($vdtls[$l]['eCreatedBy'] == 'SM') {
$sql = "Select CONCAT(vFirstName,' ',vLastName) as name from " . PRJ_DB_PREFIX . "_security_manager where iSMID=" . $vdtls[$l]['iCreatedBy'];
$cusr = $this->_obj->MySQLSelect($sql);
$vdtls[$l]['createdby'] = $cusr[0]['name'];
} else {
if ($vdtls[$l]['eCreatedBy'] == 'OA') {
$sql = "Select CONCAT(vFirstName,' ',vLastName) as name from " . PRJ_DB_PREFIX . "_organization_user where iUserID=" . $vdtls[$l]['iCreatedBy'];
$cusr = $this->_obj->MySQLSelect($sql);
$vdtls[$l]['createdby'] = $cusr[0]['name'];
}
}
if ($vdtls[$l]['eModifiedBy'] == 'SM') {
$sql = "Select CONCAT(vFirstName,' ',vLastName) as name from " . PRJ_DB_PREFIX . "_security_manager where iSMID=" . $vdtls[$l]['iModifiedByID'];
$musr = $this->_obj->MySQLSelect($sql);
$vdtls[$l]['modifiedby'] = $musr[0]['name'];
} else {
if ($vdtls[$l]['eModifiedBy'] == 'OA') {
$sql = "Select CONCAT(vFirstName,' ',vLastName) as name from " . PRJ_DB_PREFIX . "_organization_user where iUserID=" . $vdtls[$l]['iModifiedByID'];
$musr = $this->_obj->MySQLSelect($sql);
$vdtls[$l]['modifiedby'] = $musr[0]['name'];
}
}
if ($vdtls[$l]['eVerifiedBy'] != '') {
$vrfyid = @explode(',', $vdtls[$l]['verifyid']);
$vrfyby = @explode(',', $vdtls[$l]['verifyby']);
$vrfydate = @explode(',', $vdtls[$l]['verifydate']);
// $vdtls[$l]['verifiedby'] = $smarty->get_template_vars('LBL_VERIFIED_BY')." ";
$vdtls[$l]['verifiedby'] = "";
$vrfynm = array();
for ($ln = 0; $ln < count($vrfyid); $ln++) {
if ($ln > 1) {
if ($vdtls[$l]['eModifiedBy'] == 'SM') {
$sql = "Select CONCAT(vFirstName,' ',vLastName) as name from " . PRJ_DB_PREFIX . "_security_manager where iSMID=" . $vdtls[$l]['iModifiedByID'];
$musr = $this->_obj->MySQLSelect($sql);
$vdtls[$l]['modifiedby'] = $musr[0]['name'];
} else {
if ($vdtls[$l]['eModifiedBy'] == 'OA') {
$sql = "Select CONCAT(vFirstName,' ',vLastName) as name from " . PRJ_DB_PREFIX . "_organization_user where iUserID=" . $vdtls[$l]['iModifiedByID'];
$musr = $this->_obj->MySQLSelect($sql);
$vdtls[$l]['modifiedby'] = $musr[0]['name'];
}
}
}
if ($vrfyby[$ln] == 'SM') {
$sql = "Select CONCAT(vFirstName,' ',vLastName) as name from " . PRJ_DB_PREFIX . "_security_manager where iSMID=" . $vrfyid[$ln];
$vusr = $this->_obj->MySQLSelect($sql);
if (trim($vusr[0]['name']) == '') {
$vusr[0]['name'] = 'Someone';
}
if (!in_array($vusr[0]['name'] . "({$vrfyby[$ln]})" . '-' . DateTime($vrfydate[$ln], '0'), $vrfynm)) {
$vrfynm[] = $vusr[0]['name'] . "({$vrfyby[$ln]})" . '-' . DateTime($vrfydate[$ln], '0');
if ($vdtls[$l]['verifiedby'] != "") {
$vdtls[$l]['verifiedby'] .= ', ';
// $vdtls[$l]['verifiedby'] .= ' <br/> <label style="display:inline-block;width:105px;"> </label> ';
$vdtls[$l]['verifiedby'] .= '<br/>';
}
// $vdtls[$l]['verifiedby'] .= "<span style='display:inline-block; width:190px;'>".$vusr[0]['name']." ($vrfyby[$ln])"."</span> "; // .DateTime($vrfydate[$ln],'7');
$vdtls[$l]['verifiedby'] .= $vusr[0]['name'] . " ({$vrfyby[$ln]}) ";
}
} else {
if ($vrfyby[$ln] == 'OA') {
$sql = "Select CONCAT(vFirstName,' ',vLastName) as name from " . PRJ_DB_PREFIX . "_organization_user where iUserID=" . $vrfyid[$ln];
$vusr = $this->_obj->MySQLSelect($sql);
if (trim($vusr[0]['name']) == '') {
$vusr[0]['name'] = 'Someone';
}
if (!in_array($vusr[0]['name'] . "({$vrfyby[$ln]})" . '-' . DateTime($vrfydate[$ln], '0'), $vrfynm)) {
$vrfynm[] = $vusr[0]['name'] . "({$vrfyby[$ln]})" . '-' . DateTime($vrfydate[$ln], '0');
if ($vdtls[$l]['verifiedby'] != "") {
$vdtls[$l]['verifiedby'] .= ', ';
// $vdtls[$l]['verifiedby'] .= ' <br/> <label style="display:inline-block;width:105px;"> </label> ';
$vdtls[$l]['verifiedby'] .= '<br/>';
}
// $vdtls[$l]['verifiedby'] .= "<span style='display:inline-block; width:190px;'>".$vusr[0]['name']." ($vrfyby[$ln])"."</span> "; // .DateTime($vrfydate[$ln],'7');
$vdtls[$l]['verifiedby'] .= $vusr[0]['name'] . " ({$vrfyby[$ln]}) ";
}
}
}
}
}
if ($vdtls[$l]['eRejectedBy'] != '') {
$rjtid = @explode(',', $vdtls[$l]['rejectid']);
$rjtby = @explode(',', $vdtls[$l]['rejectby']);
$rjtdate = @explode(',', $vdtls[$l]['rejectdate']);
//$vdtls[$l]['rejectedby'] = $smarty->get_template_vars('LBL_REJECTED_BY')." ";
$vdtls[$l]['rejectedby'] = "";
$rjtnm = array();
for ($ln = 0; $ln < count($rjtid); $ln++) {
if ($ln > 1) {
//.........这里部分代码省略.........