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

2009-09-02 Thread Brendon Kozlowski (Realm)

I use the following code:

$this->User->saveField('lastlogin', date('Y-m-d H:i:s'));

"lastlogin" is a field in my users table, so adjust your name/table
accordingly.
Also, if your server is not in the same timezone as you are, but you'd
like it to be, you'll probably want to add the following snippet to
your app/config/bootstrap.php file:
date_default_timezone_set('America/New_York');
You can find your timezone from the PHP site. 
http://php.net/manual/en/timezones.php
(<-- english version, I couldn't find the language agnostic short link
to the page)

On Sep 2, 10:29 am, brian  wrote:
> If you're using Postgres or MySQL, at least, the format should be:
>
> -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 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.- Hide quoted text -
>
> - Show quoted text -
--~--~-~--~~~---~--~~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



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

2009-09-02 Thread brian

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

-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 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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Set the timestamp to current server time manually...

2009-09-02 Thread gparra

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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---