note 68113 deleted from ref.datetime by nlopess

From: Date: Fri, 08 Sep 2006 12:02:09 +0000
Subject: note 68113 deleted from ref.datetime by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-116898@lists.php.net to get a copy of this message
Note Submitter: flintjt at NOSPAMATALL dot hotmail dot com ---- Here are some rough patterns for matching some different date styles for building your own date conversion functions. The excel patterns relate to what you would find in MS Excel. ######################################### # Patterns for matching different date styles: # Using Perl style pattern matching for preg_match: /* Explained: unix - unix timestamp dates excel_date - Excel date stamp like "38911". excel_dt - Excel date/time stamp like "38911.4726469907". excel_time - Excel time stamp like ".4726469907". excel_dot - This one accepts either an Excel date stamp like "38911" or an Excel date/time stamp "38911.4726469907". */ ######################################### $unix_pattern = '/^(\d{10})$/'; $excel_date_pattern = '/^(\d{5})$/'; $excel_dt_pattern = '/^(\d{5})\.+(\d+)$/'; $excel_time_pattern = '/^\.+(\d+)$/'; $excel_dot_pattern = '/^(\d{5})\.*(\d*)$/'; ######################################### # Usage: $orig_v = "38911.4726469907"; if(preg_match($excel_dt_pattern, $orig_v, $matches)) { print "excel_dt_pattern $unix_v = $orig_v"; }#End of if value is a usuable excel date/timestamp: #########################################

« previous php.notes (#116898) next »