PhpRiot
Become Zend Certified

Prepare for the ZCE exam using our quizzes (web or iPad/iPhone). More info...


When you're ready get 7.5% off your exam voucher using voucher CJQNOV23 at the Zend Store

Create the Actual Date

The simplest way of creating a date object is to create the actual date. You can either create a new instance with new Zend_Date() or use the convenient static method Zend_Date::now() which both will return the actual date as new instance of Zend_Date. The actual date always include the actual date and time for the actual set timezone.

Example 173. Date Creation by Instance

Date creation by creating a new instance means that you do not need to give an parameter. Of course there are several parameters which will be described later but normally this is the simplest and most used way to get the actual date as Zend_Date instance.

<?php
$date 
= new Zend_Date();

Example 174. Static Date Creation

Sometimes it is easier to use a static method for date creation. Therefor you can use the now() method. It returns a new instance of Zend_Date the same way as if you would use new Zend_Date(). But it will always return the actual date and can not be changed by giving optional parameters.

<?php
$date 
Zend_Date::now();

Zend Framework