本文整理汇总了PHP中ADOConnection::UnixDate方法的典型用法代码示例。如果您正苦于以下问题:PHP ADOConnection::UnixDate方法的具体用法?PHP ADOConnection::UnixDate怎么用?PHP ADOConnection::UnixDate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ADOConnection
的用法示例。
在下文中一共展示了ADOConnection::UnixDate方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UnixDate
/**
* @param $v is a date string in YYYY-MM-DD format
*
* @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format
*/
function UnixDate($v)
{
return ADOConnection::UnixDate($v);
}
示例2: testdb
function testdb(&$db, $createtab = "create table ADOXYZ (id int, firstname char(24), lastname char(24), created date)")
{
global $ADODB_vers, $ADODB_CACHE_DIR, $ADODB_FETCH_MODE, $ADODB_COUNTRECS;
//adodb_pr($db);
?>
<form method=GET>
</p>
<table width=100% ><tr><td bgcolor=beige> </td></tr></table>
</p>
<?php
$create = false;
/*$ADODB_FETCH_MODE = ADODB_FETCH_NUM;
$rs = $db->Execute('select lastname,firstname,lastname,id from ADOXYZ');
$arr = $rs->GetAssoc();
echo "<pre>";print_r($arr);
die();*/
if (!$db) {
die("testdb: database not inited");
}
global $EXECS, $CACHED;
$EXECS = 0;
$CACHED = 0;
//$db->Execute("drop table adodb_logsql");
if (rand() % 3 == 0) {
@$db->Execute("delete from adodb_logsql");
}
$db->debug = 1;
$db->fnExecute = 'CountExecs';
$db->fnCacheExecute = 'CountCachedExecs';
if (empty($_GET['nolog'])) {
echo "<h3>SQL Logging enabled</h3>";
$db->LogSQL();
/*
$sql =
"SELECT t1.sid, t1.sid, t1.title, t1.hometext, t1.notes, t1.aid, t1.informant,
t2.url, t2.email, t1.catid, t3.title, t1.topic, t4.topicname, t4.topicimage,
t4.topictext, t1.score, t1.ratings, t1.counter, t1.comments, t1.acomm
FROM `nuke_stories` `t1`, `nuke_authors` `t2`, `nuke_stories_cat` `t3`, `nuke_topics` `t4`
WHERE ((t2.aid=t1.aid) AND (t3.catid=t1.catid) AND (t4.topicid=t1.topic)
AND ((t1.alanguage='german') OR (t1.alanguage='')) AND (t1.ihome='0'))
ORDER BY t1.time DESC";
$db->SelectLimit($sql);
echo $db->ErrorMsg();*/
}
$ADODB_CACHE_DIR = dirname(TempNam('/tmp', 'testadodb'));
$db->debug = false;
//print $db->UnixTimeStamp('2003-7-22 23:00:00');
$phpv = phpversion();
if (defined('ADODB_EXTENSION')) {
$ext = ' Extension ' . ADODB_EXTENSION . ' installed';
} else {
$ext = '';
}
print "<h3>ADODB Version: {$ADODB_vers} Host: <i>{$db->host}</i> Database: <i>{$db->database}</i> PHP: {$phpv} {$ext}</h3>";
flush();
if (function_exists('date_default_timezone_set')) {
date_default_timezone_set('Asia/Kuala_Lumpur');
}
$arr = $db->ServerInfo();
print_r($arr);
echo E_ALL, ' ', E_STRICT, "<br>";
$e = error_reporting(E_ALL | E_STRICT);
echo error_reporting(), '<p>';
flush();
#$db->debug=1;
$tt = $db->Time();
if ($tt == 0) {
echo '<br><b>$db->Time failed</b>';
} else {
echo "<br>db->Time: " . date('d-m-Y H:i:s', $tt);
}
echo '<br>';
echo "Date=", $db->UserDate('2002-04-07'), '<br>';
print "<i>date1</i> (1969-02-20) = " . $db->DBDate('1969-2-20');
print "<br><i>date1</i> (1999-02-20) = " . $db->DBDate('1999-2-20');
print "<br><i>date1.1</i> 1999 = " . $db->DBDate("'1999'");
print "<br><i>date2</i> (1970-1-2) = " . $db->DBDate(24 * 3600) . "<p>";
print "<i>ts1</i> (1999-02-20 13:40:50) = " . $db->DBTimeStamp('1999-2-20 1:40:50 pm');
print "<br><i>ts1.1</i> (1999-02-20 13:40:00) = " . $db->DBTimeStamp('1999-2-20 13:40');
print "<br><i>ts2</i> (1999-02-20) = " . $db->DBTimeStamp('1999-2-20');
print "<br><i>ts3</i> (1970-1-2 +/- timezone) = " . $db->DBTimeStamp(24 * 3600);
print "<br> Fractional TS (1999-2-20 13:40:50.91): " . $db->DBTimeStamp($db->UnixTimeStamp('1999-2-20 13:40:50.91+1'));
$dd = $db->UnixDate('1999-02-20');
print "<br>unixdate</i> 1999-02-20 = " . date('Y-m-d', $dd) . "<p>";
print "<br><i>ts4</i> =" . ($db->UnixTimeStamp("19700101000101") + 8 * 3600);
print "<br><i>ts5</i> =" . $db->DBTimeStamp($db->UnixTimeStamp("20040110092123"));
print "<br><i>ts6</i> =" . $db->UserTimeStamp("20040110092123");
print "<br><i>ts7</i> =" . $db->DBTimeStamp("20040110092123");
flush();
// mssql too slow in failing bad connection
if (false && $db->databaseType != 'mssql') {
print "<p>Testing bad connection. Ignore following error msgs:<br>";
$db2 = ADONewConnection();
$rez = $db2->Connect("bad connection");
$err = $db2->ErrorMsg();
print "<i>Error='{$err}'</i></p>";
if ($rez) {
print "<b>Cannot check if connection failed.</b> The Connect() function returned true.</p>";
}
//.........这里部分代码省略.........
示例3: DBDate
/**
* Converts a date "d" to a string that the database can understand.
*
* @param d a date in Unix date time format.
*
* @return date string in database date format
*/
function DBDate($d)
{
if (empty($d) && $d !== 0) {
return 'null';
}
if (is_string($d) && !is_numeric($d)) {
if ($this->isoDates) {
return "'{$d}'";
} else {
$d = ADOConnection::UnixDate($d);
}
}
return adodb_date($this->fmtDate, $d);
}
示例4: DBDate
/**
* Converts a date "d" to a string that the database can understand.
*
* @param d a date in Unix date time format.
*
* @return date string in database date format
*/
function DBDate($d)
{
if (empty($d) && $d !== 0) {
return 'null';
}
if (is_string($d) && !is_numeric($d)) {
if ($d === 'null' || strncmp($d, "'", 1) === 0) {
return $d;
}
if ($this->isoDates) {
return "'{$d}'";
}
$d = ADOConnection::UnixDate($d);
}
return adodb_date($this->fmtDate, $d);
}