Re: date
| From: | Heikki Korpela | Date: | Thu, 31 Aug 2000 14:06:57 +0000 |
| Subject: | Re: date | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-14611@lists.php.net to get a copy of this message | ||
n e t b r a i n wrote:
> Hi,
> I need a small help in order to produce a current date in the same format as
> is made by a timestamp field of MySql ... I mean, like this e.g. ---->
> 20000831205840
> anyone could help me, please?
> many thanks in advance
> max
print MySQLTime(time());
function MySQLTime($timestamp) {
return strftime("%Y-%m-%d %H:%M:%S", $timestamp);
}
Would do the 2000-08-31 20:58:40 (datetime)
Or:
function MySQLTime($timestamp) {
return strftime("%Y%m%d%H%M%S", $timestamp);
}
Would do what you asked for.
Or, you could do:
$query = "SELECT FROM_UNIXTIME(".time().") AS tst";
$result = mysql('database', $query);
$row = mysql_fetch_array($query);
print $row['tst'];
Or, you could insert 'NULL' in the timestamp field in MySQL, which
will update it
Or, if the timestamp field is first timestamp field on row in MySQL,
just update the row
Or, use CURRENT_TIMESTAMP in MySQL
--
| Heikki Korpela | heikki.korpela@wapit.com | tel. +358 50 3838 609 |
| Software Developer, Wapit Finland | http://www.wapit.com |
--
"I name you ... Esmeralda Margaret Note Spelling of Lancre!"
-- (Terry Pratchett, Carpe Jugulum)