Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>strftime</code> will work fine with a <code>Y-m-d H:i:s</code> format as it's unambiguous. </p> <p>On the other hand, it gets confused with <code>H:i:s m/d/y</code>, as it can be interpreted as <code>H:i:s d/m/Y</code>. Think about the date 02/03/2013 - m/d/y would suggest that it's the 3rd of Feb, whereas d/m/Y would suggest that it's 2nd of March.</p> <p>In other words, to ensure we get the right date every time, we have to be more specific. <code>date_create_from_format('H:i:s m/d/y', $_date)</code> will give you a DateTime object corresponding to the correct date, if the date given is indeed in the 'H:i:s m/d/y' format.</p> <pre><code>// Retrieve the date string $_date=$record-&gt;getElementsByTagName("od"); $_date=((!empty($_date))?$_date-&gt;item(0)-&gt;nodeValue:""); // Standardize it $_date = get_date( $_date ); $_date .= (trim($_date) != "") ? "Z" : ""; xmlrpc_set_type($_date, 'datetime'); function get_date( $rawDate ) { // Clean date string if(strpos($rawDate,".")!==false) { $rawDate=substr($rawDate,0,strpos($rawDate,".")); } // Attempt converting from m/d/y AND m/d/Y formats $date = date_create_from_format('H:i:s m/d/y', $rawDate); if( false === $date ) $date = date_create_from_format('H:i:s m/d/Y', $rawDate); if( !empty($date) ) { return $date-&gt;format('H:i:s m/d/Y'); // Convert the date to a string again } // If neither works, try using strtotime instead $date = @strtotime($rawDate); $date = !empty($date) ? date('H:i:s m/d/y', $date) : false; return $date; } </code></pre> <p>Hope that helps!</p>
    singulars
    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.
    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