CFormatter::formatDate and formatDateTime should also accept strings in strtotime() format #291

Closed
qiangxue opened this Issue Feb 15, 2012 · 0 comments

Projects

None yet

2 participants

@qiangxue
Member

It's very common to use DATE and DATETIME fields in MySQL. CFormatter's date methods don't accept these. This is inconvenient, because several components use this formatter. For example when you want to create a CGridView like:

'columns'=>array(
'createdAt:datetime',

it will throw an error, because the underlying CFormatter always expects a UNIX timestamp.

It should implement the same logic as in CDateFormatter::format() where the type of the supplied value is tested before:

$value=ctype_digit($value) ? (int)$value : strtotime($value);

Migrated from http://code.google.com/p/yii/issues/detail?id=2878

@francistm francistm referenced this issue Aug 8, 2012
Closed

fix ehn #291 #1172

@cebe cebe added a commit that closed this issue Sep 3, 2012
@cebe cebe fixes #291 CFormatter dates can now be strtotime values
makes #1172 obsolete
cdefc64
@cebe cebe closed this in cdefc64 Sep 3, 2012
@cebe cebe was assigned Sep 3, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment