Re: Change created/modified to unix time
On Sat, Jul 21, 2012 at 6:26 PM, Alex <amearns@gmail.com> wrote:
> Hi,
>
> I currently make use of the created and modified fields throughout my
> application but being datetime fields, performing searches/comparisons isn't
> as fast as they could be if unix timestamps were used.
Where are you doing these searches? If in the database I don't think
there would be much of a performance hit.
You could do a conversion in AppModel::afterFind and add a new key,
'timestamp' to the data for each record. Or you could even have the
database include it in the results for you, for that matter.
> I realise there may be the excuse that formatting would be required as unix
> timestamps are unreadable, but this is also the case with the current setup
> as how many people use YYYY-MM-DD HH:MM:SS when displaying dates? it's
> usually DD-MM-YYYY or MM-DD-YYYY.
No it's not usually those formats. YYYY-MM-DD is an ISO standard for
good reason. It sorts naturally, for one thing. Another obvious reason
is right there in your comment: "DD-MM-YYYY or MM-DD-YYYY" Yes? Which
is it then? They're ambiguous, so should be avoided.
Now, if only some countries would also adopt the metric system. ;-)
> What does everyone else think?
>
> Is there a way to convert the current created/modified fields to UNIX
> timestamps with current CakePHP?
I'll leave it for someone else to say. I know that I have seen where
that is set but cannot remember now.
--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home