note 45016 added to function.strtotime

From: Date: Mon, 23 Aug 2004 13:58:10 +0000
Subject: note 45016 added to function.strtotime
Groups: php.notes 
Request: Send a blank email to php-notes+get-75166@lists.php.net to get a copy of this message
If you're using SQL Server, it returns dates as a fixed length field, which means you'll often get whitespace at the end of a date. If you use strtotime() on such a date, it will behave correctly about half the time. The other half, it will return -1 (to demonstrate, run it through a web page, and keep hitting reload, and you'll see it randomly jump back and forth). This isn't a strtotime bug, as I assume it's not designed to handle whitespace. So the solution is to trim any dates you get from SQL Server tables before using strtotime() on them. This is also a problem if you use Smarty's date formatting features. Trim dates you get from SQL Server before you send them to Smarty. ---- Manual Page -- http://www.php.net/manual/en/function.strtotime.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45016 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45016&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45016&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#75166) next »