zend-date

Saving a Zend date in the database with Doctrine 2.1

妖精的绣舞 提交于 2019-12-22 12:09:30
问题 I want to save a datetime in the database which was created with the doctrine schema tool. In my form I set a date and time and i want to save it as a datetime in the database. So i tried this: $e->setStartDateTime(new Zend_Date('2011-09-01T22:00:00',Zend_date::DATETIME)); But i get the error: PHP Fatal error: Call to undefined method Zend_Date::format() in /var/www/shared/Doctrine/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Types/DateTimeType.php on line 44 Does anyone have experience with

How print all the weeks in an year (or first monday of year)

岁酱吖の 提交于 2019-12-20 04:30:07
问题 How print all the weeks which start with monday and end with sunday.. like below ..using Zend_date 1 04-Jan-2010-10-Jan-2010 2 11-Jan-2010-17-Jan-2010 3 18-Jan-2010-24-Jan-2010 回答1: Start by finding the first monday, then you can just add 1 week until the year increments. <?php define('NL', "\n"); $year = 2010; $firstDayOfYear = mktime(0, 0, 0, 1, 1, $year); $nextMonday = strtotime('monday', $firstDayOfYear); $nextSunday = strtotime('sunday', $nextMonday); while (date('Y', $nextMonday) ==

How to use Zend_Date to print a time in a specific timezone

佐手、 提交于 2019-12-12 18:13:38
问题 In my app I use Zend_Date. I have set date_default_timezone_set('UTC') because internally and in the database I only want to have UTC times. For users I want to display it in their local time. What is the easiest way to do this? Let's say, I have in the view $user->timezone and $date, where $timezone is 'Europe/Helsinki' and $date is a Zend_Date. 回答1: This should be better documented in the manual, as it's a pretty common use case. Fortunately it's nice and easy: $date->setTimezone($user-

Work Around for Zend Date DST Bug

天大地大妈咪最大 提交于 2019-12-07 17:31:24
问题 I discovered a bug in Zend_Date when setting a time that crosses the DST change. Here's code that illustrates the problem: date_default_timezone_set('America/New_York'); echo '<pre>'; // DST BEGINS '2012-03-11 02:00:00' - "Spring Forward" $a = new Zend_Date('2012-03-11 00:00:00', 'yyyy-MM-dd HH:mm:ss'); $a->setTime('04:00:00', 'HH:mm:ss'); echo $a->toString('yyyy-MM-dd HH:mm:ss', 'iso') . ' // expected: 2012-03-11 04:00:00' . PHP_EOL; $b = new Zend_Date('2012-03-11 04:00:00', 'yyyy-MM-dd HH

How to calculate time passed with PHP or Zend_Date?

梦想与她 提交于 2019-12-06 15:37:31
问题 I'm trying to create a view helper that will display the number of minutes, hours, or days that have passed since...right now. I'm not really sure how to do it. It looks like the date comparison is working, but I don't know how to get the number. Here's what I have so far: <?php class Zend_View_Helper_RecentDate { public function recentDate($datetime) { $date = new Zend_Date($datetime); switch ($date) { case($date->isEarlier(1, Zend_Date::HOUR)): $message = 'was minutes ago'; break; case(

First day of each month

半腔热情 提交于 2019-12-06 10:24:37
问题 If I start with the current date, how can I get the first Friday of each month? I was thinking about using $date->get(Zend::WEEKDAY) and comparing that to Friday and then with DAY and checking if it is less than or equal to 7. Then adding 1 month onto it. There must be something simpler? 回答1: How about $firstFridayOfOcober = strtotime('first friday of october'); Or turn it into a handy function:- /** * Returns a timestamp for the first friday of the given month * @param string $month *

Work Around for Zend Date DST Bug

大城市里の小女人 提交于 2019-12-05 21:54:44
I discovered a bug in Zend_Date when setting a time that crosses the DST change . Here's code that illustrates the problem: date_default_timezone_set('America/New_York'); echo '<pre>'; // DST BEGINS '2012-03-11 02:00:00' - "Spring Forward" $a = new Zend_Date('2012-03-11 00:00:00', 'yyyy-MM-dd HH:mm:ss'); $a->setTime('04:00:00', 'HH:mm:ss'); echo $a->toString('yyyy-MM-dd HH:mm:ss', 'iso') . ' // expected: 2012-03-11 04:00:00' . PHP_EOL; $b = new Zend_Date('2012-03-11 04:00:00', 'yyyy-MM-dd HH:mm:ss'); $b->setTime('00:00:00', 'HH:mm:ss'); echo $b->toString('yyyy-MM-dd HH:mm:ss', 'iso') . ' //

PHP Zend date format

自作多情 提交于 2019-12-05 16:11:24
问题 I want to input a timestamp in below format to the database. yyyy-mm-dd hh:mm:ss How can I get in above format? When I use $date = new Zend_Date(); it returns month dd, yyyy hh:mm:ss PM I also use a JavaScript calender to insert a selected date and it returns in dd-mm-yyyy format Now, I want to convert these both format into yyyy-mm-dd hh:mm:ss so can be inserted in database. Because date format not matching the database field format the date is not inserted and only filled with * 00-00-00 00

How to calculate time passed with PHP or Zend_Date?

老子叫甜甜 提交于 2019-12-04 20:40:26
I'm trying to create a view helper that will display the number of minutes, hours, or days that have passed since...right now. I'm not really sure how to do it. It looks like the date comparison is working, but I don't know how to get the number. Here's what I have so far: <?php class Zend_View_Helper_RecentDate { public function recentDate($datetime) { $date = new Zend_Date($datetime); switch ($date) { case($date->isEarlier(1, Zend_Date::HOUR)): $message = 'was minutes ago'; break; case($date->isEarlier(24, Zend_Date::HOUR)): $message = 'was hours ago'; break; case($date->isEarlier(48, Zend

First day of each month

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-04 13:48:23
If I start with the current date, how can I get the first Friday of each month? I was thinking about using $date->get(Zend::WEEKDAY) and comparing that to Friday and then with DAY and checking if it is less than or equal to 7. Then adding 1 month onto it. There must be something simpler? How about $firstFridayOfOcober = strtotime('first friday of october'); Or turn it into a handy function:- /** * Returns a timestamp for the first friday of the given month * @param string $month * @return type int */ function firstFriday($month) { return strtotime("first friday of $month"); } You could use