zend-date

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

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...

formatting date from twitter response Zend Framework

Hi everybody, im trying to formatting the date field 'created_at' from Twitter API response with Zend_Date. I want output the date like this: 21 of July of 2009, 12:30:00 (for example) What format is this?: Fri Oct 23 15:47:42 +0000 2009 thanks a lot ...

How to calculate time passed with PHP or Zend_Date?

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 r...

Automatically selecting dates from databases as Zend_Date objects

From what I understand, the best way to deal with dates in the Zend Framework is to select them as a Unix timestamp from the database. Quick Creation of Dates from Database Date Values // SELECT UNIX_TIMESTAMP(my_datetime_column) FROM my_table $date = new Zend_Date($unixtimestamp, Zend_Date::TIMESTAMP); I think it's a pain that there...

Problem with Zend_Date and ISO_8601 format

Frankly, I'm flummoxed. Can anyone tell me why I would get a failure message with this code? $date = Zend_Date::now(); $date = $date->getIso(); if(Zend_Date::isDate($date, Zend_Date::ISO_8601)) { print('success'); } else { print('failure'); } exit; It also fails if I just pass in a Zend_Date object. UPDATE: a var_dump of...

Zend_Date: How to get the date of an upcoming day?

I want to get the date of the closest Monday in the future (i.e. not in the past). So if today is Tuesday (Dec 1, 2009) I want to get the date of Monday (Dec 7, 2009). How can I do this with Zend_Date? Solution: Let's say today is Tuesday and we wanted to get the upcoming Monday. Monday is 6 days into the future. So, we would add 6 d...

PHP loop, date sorting challenge...

I'm having trouble trying to figure out how to achieve this programming challenge in my Zend Framework application: I need to create an array that looks like this: $array = array( 0 => stdClass()->monthName ->monthResources = array() 1 => stdClass()->monthName ->monthResources = array() ); ...

Zend_Date::toString() outputs the wrong year. Bug in my code, or Zend_Date?

I'm using Zend_Date to set and get the year, but it is not being set as the correct year. I set the year as 2010, and it returns the year as 2009. What am I doing wrong? Is there a bug in Zend_Date? $date = new Zend_Date('2010-01-03', 'YYYY-MM-dd'); echo $date->toString('MMMM d, YYYY'); //outputs January 3, 2009 The year must be being...

Internationalized date formatting with Zend_Date ( Japanese )

Disclaimer: you might need to install a font/typeface which supports Japanese if you see messed up characters. I'm trying to replicate what I've been doing so far with setlocale and strftime: setlocale(LC_ALL, 'ja_JP.utf8'); $time = mktime(); echo strftime('%x', $time), '<br>'; Output: 2010年01月06日 Using Zend_Date - but I...

Zend_Date language translation

Hello ! I have a function that returns me a date string using Zend_Date. $date = new Zend_Date(); $date->setOptions(array('format_type' => 'php')); $date->setTimestamp($timestamp); return $date->toString($format); When I set $format to 'l, d F Y' I expect something like: Środa, 13 stycznia 2010 (correct polish string what means W...

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

Hi all, 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 ...

how to get the number of weeks of current year using Zend_Date class

how can we get number of weeks of current year, for example if it's 2009 there are 53 weeks and 2010 has 52 ...

How to create a datetime validator in a Zend Framework form?

By default a Zend Framework date validator uses the date format yyyy-MM-dd: $dateValidator = new Zend_Validate_Date(); But I want to add hour and minute validation. In other words, I want to require the user to enter the hour and minute. But the following does not work: $dateValidator = new Zend_Validate_Date('yyyy-MM-dd hh:ii'); I...

Filtering table rows with higher date than provided.

I'm currently trying to do it that way: // Creating date object $date = new Zend_Date(); // Adding to it 4 weeks $date->add('4', Zend_Date::WEEK); // it's expire day // Getting date in integer(i guess it's unix timestamp yes?) $date->get(); // Saving it to Mysql in field 'expire' with type Varchar Then, when need...

zend_date relative time

Hi, i want to make stackoverflow timestamps(X minutes ago, etc). How i can make it using zend_date? I found http://stackoverflow.com/questions/1639892/how-to-calculate-time-passed-with-php-or-zend-date this realisation, but it uses other library. Are there any different ways? ...

Zend_Date and setting timezone on instation

I have a ZF app and am saving times as UTC in MySQL db. When I retrieve, them I'd like to tell Zend_Ddate that they are UTC rather than the timezone set in php.ini of 'America/Los Angeles'. Currently, I'm instantiating like this: $date=new Zend_Date($item['created_on_utc'],Zend_Date::ISO_8601,'en_US'); but feel like there should be a...

Zend Date -- day difference

Hi All, I have the below line of codes $day1 = new Zend_Date('2010-03-01', 'YYYY-mm-dd'); $day2 = new Zend_Date('2010-03-05', 'YYYY-mm-dd'); $dateDiff = $day2->getDate()->get(Zend_Date::TIMESTAMP) - $day1->getDate()->get(Zend_Date::TIMESTAMP); $days = floor((($dateDiff / 60) / 60) / 24); return $days; this will return 4 But if ga...

How can I simply change the Timezone Offset with Zend_Date?

I'm using Zend_Date to manage dates/times in a scheduling app. The only way I'm able to determine the user's Timezone is via Javascript which only gives a Timezone Offset. Zend_Date only seems to take Timezones in the 'America/New_York' format. Is there a way to get the users timezone in this format or set the Timezone Offset with Ze...

Zend Date Weirdness - Missing Configuration?

I'm getting odd output from the getDate() function. It's supposed to return a date without the time parts, but I am getting time parts. Am I missing some configuration option that would correct this? Sample Code: date_default_timezone_set('America/New_York'); $date = new Zend_Date(array( 'year' => 2010, 'month' => 3, 'day...

Zend_Date returning strange format online - works fine on my localhost

I have the following code to format dates: $date = new Zend_Date(); $date->set(strtotime($some_date); echo ($date->get(Zend_Date::DATE_FULL)); it wokrs fine on my localhost outputting the date as I need it to be outputted. However on my online server the dates are outputted in a weird numerical way. i.e the numeric value fo the Day a...