Hot answers tagged

6

Finally I found the solution for this Error by passing the object of DateTimeZone as a parameter (notice the $date->setTimezone(new DateTimeZone($tz)); in the code bellow). It's working fine. if($date === null ) { $date = JFactory::getDate(); $tz = JFactory::getConfig()->get( 'offset' ); $date->setTimezone(new DateTimeZone($tz)); //here! $...


5

OK so I believe this to be true :) I was looking for a Joomla answer whereas I needed to use some Joomla and some php to get what I wanted. JDate works off UTC timezone by default. So you need to apply your server timezone offset (or user timezone offset) to the date first. That way, $config = JFactory::getConfig(); $offset = $config->get('offset'); ...


4

You should be able to use the following if you want to add 15 working/business days: $date = JFactory::getDate(); $newDate = new JDate($date . ' +15 Weekday'); $toFormat = $newDate->format('Y-m-d'); Today is the 24th April 2015, so $date (excluding the time), will output the following: 2015-04-24 and $toFormat will output the following: 2015-...


4

Go to Extension Manager -> Language Manager. Select Overrides. Select the Language for which you want to set an override and change the date format. Add a new override. Select the Constant option (Search for the constant DATE_FORMAT_LC2/LC3/LC4). Modify its value and save the changes. Just remove the text and type in the format you'd like. For example, if ...


4

Open the file /libraries/joomla/factory.php and search for getDate() function: public static function getDate($time = 'now', $tzOffset = null) The default value of time zone offset ($tzOffset) is null and not 0. It may be due to a mistake in Joomla documentation or it's for versions older than 2.5. In Joomla 3, $date_zero_offset = JFactory::getDate('now', ...


3

JHtml::date() will automatically use your timezone setting. JHtml::date('now', 'Y-m-d H:i:s'); See the answer here


3

I always compare dates with unix timestamps. In this day, there is no question about minutes or timezones. if ($expected->toUnix() < $today->toUnix()) On the other hand, if you want to only compare only the date part, you can just format the dates and compare them with the simple string comparison: if ($expected->format('Y-m-d') < $today-&...


3

By default JHtml::date() accounts for user's timezone, which, if not set, defaults to site's timezone (set in Global Configuration). Pass another argument with value null to leave the date as is. Also, because you're using a hardcoded string for format, you don't need to wrap it in JText::_(): echo JHtml::_('date', $edit, 'l F j Y g:ia', null); You should ...


3

It might be an idea to get the offset from your Global Config like so: $date = JFactory::getDate($input='now', 'UTC'); $tz = JFactory::getConfig()->getValue('config.offset'); $date->setOffset($tz); echo $date->toFormat(); To make life a little easier and have less code, I would suggest using JHtml::date echo JHtml::date($input = 'now', 'm/d/Y',...


2

Sorry that answering on so old question, but just wanted to say that there is no built-in way to make it. You should consider to create your own field type and implement the logic there.


2

Haven't used JDate for this, but the below PHP code works it for us: // Current Date $current_date = date('Y-m-d'); list ($year, $month, $day) = explode('-', $current_date); $today = new DateTime(); $today->setDate($year, $month, $day); // This Quarter $month = $month % 3 ? $month + 3 - ($month % 3) : $month; // $this_date = new DateTime(); $this_date-&...


2

I looked at the code for this. JDate::dateformat is public, which means ANY code can modify the value. I would start doing a grep/search through my source tree (and any plugins/modules/libraries) to look for assignments to it. Looking at the Time difference issue, what I think is that JFactory() is constructing the date two different ways. The first, with ...


2

$mydate = $item->displayDate; simply refers to the date string, therefore $mydate is not an object and you cannot format() it. You'll need to pass the date string through JHtmlDate like so: echo JHtml::_('date', $item->displayDate, 'j M Y');


1

You could create a language override for the Persian language. The Joomla documentation shows you how to do that: https://docs.joomla.org/J3.x:Language_Overrides_in_Joomla You could copy the following English language strings from /language/en-GB/en-GB.ini to your Persian language override: DATE_FORMAT_LC="l, d F Y" DATE_FORMAT_LC1="l, d F Y" ...


1

The functionality you're referring to has not been implemented for the Last Visit Date in the Joomla User Manager. If you open the following file and go to line 152: administrator\components\com_users\views\users\tmpl\default.php you will see the following: <?php echo JHtml::_('date', $item->lastvisitDate, 'Y-m-d H:i:s'); ?> You can create a ...


1

I cannot be too specific without knowing the exact database table structure and data, but it seems that your date values are being stored and processed as: dd [delimiter] mm [delimiter] yyyy (delimiters may logically be / or -) For instance, if you are storing the date as a VARCHAR and the string looks like 22/08/17, 30/08/17,23/11/17,30/11/17 then it is ...


1

Modifying page layout The full AMP page layout as well as all sections are implemented by wbAMP as JLayout. This means you can override any part of the output through your template overrides. Please refer to Joomla! documentation for details. wbAMP JLayouts are located in the /plugins/system/wbamp/layouts folder. If you are trying to create ...


1

I fixed it by creating JDate object $time_offset = "Australia/Sydney"; $start_time = "2015-07-31 15:03:00"; $date_end = JDate::getInstance('now', $time_offset); $date_start = new JDate($start_time); $date_start->setTimezone(new DateTimeZone($time_offset)); echo $date_end; echo $date_start;


1

Rather than trying to format using mysql, i would rather to do it in php directly using JDate. for example: // Your date from database $myStringDate = '2018-06-19 09:04:05'; // Use it in a JDate instance $date = JFactory::getDate($myStringDate); // Output using the format of your choice (see http://php.net/manual/en/function.date.php) echo $date->...


1

The joomla use in php code articles this code to show date and time: <?php echo JHtml::_( 'date', $article->displayDate, $this->escape($this->params->get('date_format', JText::_('DATE_FORMAT_LC3'))) ); ?> Joomla use string 'DATE_FORMAT_LC3' to format date and time. If your site was use language english you can change the file in: /...


Only top voted, non community-wiki answers of a minimum length are eligible