Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As explained in the manual, <a href="http://es2.php.net/date_create" rel="nofollow">date_create()</a> is an alias for <a href="http://es.php.net/manual/en/datetime.construct.php" rel="nofollow">DateTime::__construct()</a>. And there we can read:</p> <blockquote> <p><strong>Return Values</strong><br>Returns a new DateTime instance. Procedural style returns FALSE on failure.</p> </blockquote> <p>So it's pretty clear where the boolean comes from.</p> <p>Now, your code shows many conversions from Unix timestamp to string and viceversa but not the value you start from, so it's impossible to point out the exact source of the problem. But I'd say you have certain confusion about the data types involved in date handling. Here's a little summary:</p> <ul> <li><p>Unix timestamp: it's an integer that counts the number of seconds since the Unix Epoch (Jan 1970). It's the value handled by legacy date functions that receive an integer as argument or return one.</p></li> <li><p>DateTime: it's the new object-oriented date feature introduced in PHP/5.2.</p></li> <li><p>Strings: it's not a standardised format per-se so it should only be used for display purposes or as intermediate format (for instance, to insert a date into a database).</p></li> </ul> <p>Sadly, the DateTime constructor only accepts strings and does not even allow to tell the exact format (IMHO, a not well-thought design decision). To reduce the potential ambiguity (is <code>10/11/2011</code> 10th Nov. or 11 Oct?), I suggest you use the <code>"YYYY-MM-DD"</code> format.</p> <p>A tip: decide whether to use timestamps or DateTime objects and stick to that. It'll make your live easier.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload