Pages

Showing posts with label Date. Show all posts
Showing posts with label Date. Show all posts

Tuesday, July 3, 2012

Date Conversion using PHP using DateTime object

$duedate=Datetime::CreateFromFormat('d-m-y',$this->data['Payment']['duedate']);

$converted_due_date=$duedate->format('Y-m-d);

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 )