Pages

Showing posts with label Timestamp. Show all posts
Showing posts with label Timestamp. Show all posts

Tuesday, July 3, 2012

Submitting current timestamp in cakephp

To Submit Current timestamp in cakephp use

DboSource::expression('NOW()');

example

$this->data['SomeModel']['your_datetime_field'] = DboSource::expression('NOW()');
$this->Model->save($this->data);

Tuesday, January 17, 2012

Compare a timestamp field(Mysql) to date(PHP)

here is the where condition that should be added to your mysql qyery

where DATE_FORMAT(TimeStampFieldFromDatabase,"%Y-%m-%d")=$dateToBeCompared

Note:-$dateToBeCompared must be of type (Y-m-d) as per standard SQL format

use the DateTime PDO library class to convert the same format available in PHP 5.3.5

public string DateTime::format ( string $format )