We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1764
    • 680 Posts
    There seems to be a problem with using the Date Formatter widget on a Date/Time MySQL data type.

    The problem is that the strtotime() PHP function does not recognize the default "31-12-2005 12:30:00" MySQL date/time format. So I wrote a small hack.

    The code below should replace the "date" case in manager/includes/tmplvars.format.inc.php. Maybe this could make it into TP4?

    			case "date":
    				$value = parseInput($value);
    				
    // START HACK - Adam Crownoble 8/3/2005
    
    				// Check for MySQL style date
    				$date_match = '^([0-9]{2})-([0-9]{2})-([0-9]{4})\ ([0-9]{2}):([0-9]{2}):([0-9]{2})$';
    				if(ereg($date_match, $value, $matches)) {
    					$timestamp = mktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[1], $matches[3]);
    
    				// If it's not a MySQL style date, then use strtotime to figure out the date
    				} else {
    					$timestamp = strtotime($value);
    				}
    
    // END HACK
    
    				$p = $params['format'] ? $params['format']:"%A %d, %B %Y";
    //				$o = strftime($p,strtotime($value)); // OLD CODE
    				$o = strftime($p,$timestamp); // HACK Adam Crownoble 8/3/2005
    				break;
    


    I have also attache the hacked TP3 tmplvars.format.inc.php file so you can just overwrite your existing file.
      • 1764
      • 680 Posts
      Since the bug reporting forum is being closed down in favor of Flyspary, I’ve posted this issue there.

      See the bug report
      • Thanks Adam. smiley
          Ryan Thrash, MODX Co-Founder
          Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me