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!
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');
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:
and $toFormat will output the following:
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 ...
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', ...
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-&...
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 ...
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');
To make life a little easier and have less code, I would suggest using JHtml::date
echo JHtml::date($input = 'now', 'm/d/Y',...
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();
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 ...
$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');
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"
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:
you will see the following:
<?php echo JHtml::_('date', $item->lastvisitDate, 'Y-m-d H:i:s'); ?>
You can create a ...
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 ...
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
If you are trying to create ...
Rather than trying to format using mysql, i would rather to do it in php directly using JDate.
// 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)
The joomla use in php code articles this code to show date and time:
Joomla use string 'DATE_FORMAT_LC3' to format date and time. If your site was use language english you can change the file in: