Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8599855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:29:10+00:00 2026-06-12T01:29:10+00:00

I have Created this code in a custom component that I made: $date =

  • 0

I have Created this code in a custom component that I made:

$date = date('m/d/Y h:i:s a', time())."<br>";
echo  'Current date and time is: ' . $date;

$date = JFactory::getDate();
echo 'Current date and time is: ' . $date->toFormat() ."<br>";

The first code displays the datetime correctly, but the second one displays the time +3 hours

I have checked the configuration.php file and the public $offset = ‘Europe/Athens’; and is correct. I am also changing the settings from the system configuration menu but nothing seems to be fixing the JFactory::getDate() to display the correct time.
What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T01:29:12+00:00Added an answer on June 12, 2026 at 1:29 am

    For your second parameter in the JFactory::getdate() – I think you should be specifying the time zone in a second parameter so something like JFactory::getDate($time=now, $tzOffset)

    $date = JFactory::getDate($input='now', 'UTC');
    // Set the correct time zone based on the server configuration.
    $config = JFactory::getConfig();
    $date->setOffset($config->getValue('config.offset'));
    //Print out Date
    echo $date->toFormat();
    

    On a side note it may be easier to use JHtml::date() in the component as this involves less lines and is more ‘Joomla native’. See the API page on this here. Then use a code like :

    echo JHtml::date($input = 'now', 'm/d/Y h:i:s a', false);
    

    Where $input = now specifies to use the time ‘now’. The second parameter is your format for the date and the third parameter means the time setting is set the server time. Rather than the users selected time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have made this code to open a database(created in SQLite browser) stored in
I have created a Popup that is custom component extends Canvas i want the
I have created a custom component that I am using, more conveniently, as a
I have created this Fiddle with this code: This is my problem I want
I have an array created with this code: var widthRange = new Array(); widthRange[46]
All, I am trying to code a Connect4 game. For this, I have created
I have create a vcf file that contains contacts by using this code ContentResolver
I have created a custom pipeline component which transforms a complex excel spreadsheet to
I have an SSIS Script component that needs to run some VB.NET code shortly
I created a custom textfield component that I need multiples of in a single

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.