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 8602605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T02:07:33+00:00 2026-06-12T02:07:33+00:00

If I output the date/time in index.php echo date(‘m/d/Y h:i:s a’, time()); . It’s

  • 0

If I output the date/time in index.php echo date('m/d/Y h:i:s a', time());. It’s correct. If I output the date/time anywhere after that, in an extension for example it’s off 4 hours exactly. I’ve set the timezone properly in php.ini and in Magento itself so not sure what’s causing it to be off. I’m running version 1.7.0.2.

EDIT

Ok so I’ve learned a few things.

Magento always sets the timezone to UTC in
app/mage.php

line 767: date_default_timezone_set('UTC')

So, basically you can’t use date(),time() etc. You have to set your targetting timezone in Admin->System->Configuration / General->Locale options and use something like:

$now = Mage::getModel('core/date')->timestamp(time());
echo date('m/d/y h:i:s', $now);

I could always replace line 767 with my timezone but I don’t like modifying core code. Are there any other options out there ???

  • 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-12T02:07:34+00:00Added an answer on June 12, 2026 at 2:07 am

    The preferred method in Magento seems to be using either Zend or Varien date-time objects instead of scalar values as in this example. Once you have your object you can easily convert it to other, non-server timezones with a setTimezone call.

    // a more complete example
    $datetime = Zend_Date::now();
    // admin controls this output through configuration
    $datetime->setLocale(Mage::getStoreConfig(
                 Mage_Core_Model_Locale::XML_PATH_DEFAULT_LOCALE))
             ->setTimezone(Mage::getStoreConfig(
                 Mage_Core_Model_Locale::XML_PATH_DEFAULT_TIMEZONE));
    echo $datetime->get(Zend_Date::DATETIME_SHORT);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone know how to set Visual Studio 2008 to output the current date/time
I'm using PHP to output data from an XML file, specifically the date, which
How can I output the current date and time with the defaulttimezone? When I
I have a string in standard ISO 8601 format that contains the date/time returned
I have data in an MYSQL database that looks like this: Project Date Time
So far I've tried: 'date +%Y-%m-%d_%H%M'_PostsOnly.sql With output: date\ +%Y-%m-%d_%H%M_PostsOnly.sql 2) 'date +\%Y-\%m-\%d_\%H\%M_PostsOnly'.sql With
I'm using toLocalizedTime to output a date, as below <span tal:content=python:here.toLocalisedTime(date.get('start_date'))/> This outputs eg.
I have a SQL Server 2005 output like this: Date | Result | Sum
the output should process the first date as day and second as night. I've
I am trying to output dates in the Italian format using date() as follows:

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.