Wednesday, September 2, 2009

Re: Set the timestamp to current server time manually...

If you're using Postgres or MySQL, at least, the format should be:

YYYY-MM-DD HH:MM:SS

So, you can use PHP's date function:

$this->data['Visit']['date'] = date('Y-m-d H:i:s');

I'm not so sure that 'date' is a good name for a DB column, though.

http://www.php.net/manual/en/function.date.php

On Wed, Sep 2, 2009 at 1:01 AM, gparra<gparra@gmail.com> wrote:
>
> Hi,
>
> I realize this question may be fairly easy to answer, but I just
> haven't managed to get a clear understanding of how to do it through
> the documentation or google search.
>
> I settled by using the database convention of naming my date field to
> 'created' as a datetime field in the database and in the model.
>
> This way, when I save it stores the current timestamp.
>
> However I'd like to know if there's a way I can manually set the
> timestamp using the Time helper or another time/date function in
> cakephp. Couldn't find anything similar online, I'd appreciate any
> comments.
>
> The idea is to do something like this in the controller:
>
> $this->data[Visit].['date'] = timestamp()* (I realize this could take
> any shape or form, please suggest the simplest most cakephp framework
> centric alternative).
>
> Thanks!
> German.
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
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?hl=en
-~----------~----~----~----~------~----~------~--~---

No comments: