<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >px_timestamp2string</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REL="HOME" TITLE="PHP 手册" HREF="index.html"><LINK REL="UP" TITLE="Paradox File Access" HREF="ref.paradox.html"><LINK REL="PREVIOUS" TITLE="px_set_value" HREF="function.px-set-value.html"><LINK REL="NEXT" TITLE="px_update_record" HREF="function.px-update-record.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=UTF-8"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >PHP 手册</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.px-set-value.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.px-update-record.html" ACCESSKEY="N" >下一页</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.px-timestamp2string" ></A >px_timestamp2string</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN168313" ></A ><P > (PECL)</P >px_timestamp2string -- Converts the timestamp into a string. </DIV ><DIV CLASS="refsect1" ><A NAME="AEN168316" ></A ><H2 >说明</H2 >string <B CLASS="methodname" >px_timestamp2string</B > ( resource pxdoc, float value, string format )<BR ></BR ><P > Turns a timestamp as it stored in the paradox file into human readable format. Paradox timestamps are the number of milliseconds since 1.1.0000. This function is just for convenience. It can be easily replaced by some math and the calendar functions as demonstrated in the following example. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN168331" ></A ><H2 >参数</H2 ><P > <P ></P ><DIV CLASS="variablelist" ><DL ><DT ><CODE CLASS="parameter" >pxdoc</CODE ></DT ><DD ><P > Resource identifier of the paradox database. </P ></DD ><DT ><CODE CLASS="parameter" >value</CODE ></DT ><DD ><P > Value as stored in paradox database field of type PX_FIELD_TIME, or PX_FIELD_TIMESTAMP. </P ></DD ><DT ><CODE CLASS="parameter" >format</CODE ></DT ><DD ><P > String format similar to the format used by <A HREF="function.date.html" ><B CLASS="function" >date()</B ></A >. The placeholders support by this function is a subset of those supported by <A HREF="function.date.html" ><B CLASS="function" >date()</B ></A > (Y, y, m, n, d, j, H, h, G, g, i, s, A, a, L). </P ></DD ></DL ></DIV > </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN168352" ></A ><H2 >返回值</H2 ><P > 如果成功则返回 <TT CLASS="constant" ><B >TRUE</B ></TT >,失败则返回 <TT CLASS="constant" ><B >FALSE</B ></TT >。 </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN168357" ></A ><H2 >范例</H2 ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN168360" ></A ><P ><B >例 1. Turn a paradox timestamp into a human readable form</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><code><font color="#000000"> <font color="#0000BB"><?php<br />$px </font><font color="#007700">= </font><font color="#0000BB">px_new</font><font color="#007700">();<br /><br /></font><font color="#FF8000">/* make up a date as it could be stored in */<br />/* a date field of a paradox db. */<br />/* 700000 days since 1.1.0000. */<br /></font><font color="#0000BB">$days </font><font color="#007700">= </font><font color="#0000BB">700000</font><font color="#007700">;<br /><br /></font><font color="#FF8000">/* Use the calendar functions to print a */<br />/* human readable format of the date */<br /></font><font color="#007700">echo </font><font color="#0000BB">jdtogregorian</font><font color="#007700">(</font><font color="#0000BB">$days</font><font color="#007700">+</font><font color="#0000BB">1721425</font><font color="#007700">).</font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br /></font><font color="#FF8000">/* Turn it into a timestamp as it stored in a paradox database */<br />/* Timestamps are stored in milli seconds since 1.1.0000 */<br /></font><font color="#0000BB">$stamp </font><font color="#007700">= </font><font color="#0000BB">$days </font><font color="#007700">* </font><font color="#0000BB">86400.0 </font><font color="#007700">* </font><font color="#0000BB">1000.0</font><font color="#007700">;<br /></font><font color="#FF8000">/* Add one hour */<br /></font><font color="#0000BB">$stamp </font><font color="#007700">+= </font><font color="#0000BB">3600000.0</font><font color="#007700">;<br /></font><font color="#FF8000">/* The following will output '7/15/1917 01:00:00'. */<br /></font><font color="#007700">echo </font><font color="#0000BB">px_timestamp2string</font><font color="#007700">(</font><font color="#0000BB">$px</font><font color="#007700">, </font><font color="#0000BB">$stamp</font><font color="#007700">, </font><font color="#DD0000">"n/d/Y H:i:s"</font><font color="#007700">).</font><font color="#DD0000">"\n"</font><font color="#007700">;<br /><br /></font><font color="#0000BB">px_delete</font><font color="#007700">(</font><font color="#0000BB">$px</font><font color="#007700">);<br /></font><font color="#0000BB">?></font> </font> </code></TD ></TR ></TABLE ><P >上例将输出:</P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="screen" >7/15/1917 7/15/1917 01:00:00</PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > The Julian day count as passed to <A HREF="function.jdtogregorian.html" ><B CLASS="function" >jdtogregorian()</B ></A > has a different base of 1.1.4714 b.c. and must therefore be calculated by adding 1721425 to the day count used in the paradox file. Turning the day count into a timestamp is easily done by multiplying with 86400000.0 to obtain milli seconds. </P ></DIV ><DIV CLASS="refsect1" ><A NAME="AEN168367" ></A ><H2 >参见</H2 ><P > <P ></P ><TABLE BORDER="0" ><TBODY ><TR ><TD ><A HREF="function.px-date2string.html" ><B CLASS="function" >px_date2string()</B ></A ></TD ></TR ><TR ><TD ><A HREF="function.jdtogregorian.html" ><B CLASS="function" >jdtogregorian()</B ></A ></TD ></TR ></TBODY ></TABLE ><P ></P > </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.px-set-value.html" ACCESSKEY="P" >上一页</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >起始页</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.px-update-record.html" ACCESSKEY="N" >下一页</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >px_set_value</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.paradox.html" ACCESSKEY="U" >上一级</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >px_update_record</TD ></TR ></TABLE ></DIV ></BODY ></HTML >