• BDIX
    • BDIX Shared Hosting
    • BDIX Reseller Hosting
    • BDIX KVM VPS
    • BDIX Windows VPS
  • Hosting
    • Singapore Web Hosting
    • WordPress Hosting
    • Cheap Shared Hosting
    • Turbo Hosting
  • Reseller Hosting
    • Singapore Reseller Hosting
    • USA Reseller Hosting
  • Server
    • Singapore VPS
    • USA VPS
    • Germany VPS
    • Cheap VPS
  • Domain
    • Register Domain
    • Transfer Domain
    • Domain Promos
Linkedin Twitter Youtube Facebook
  • support@prenhost.com
  • Hosting Flash Sale: Starting at $0.43/mo for a limited time
  • WhatsApp Support
  • Login
newph-transperent- newph-transperent-
  • BDIX
    • BDIX Shared Hosting
    • BDIX Reseller Hosting
    • BDIX KVM VPS
    • BDIX Windows VPS
  • Hosting
    • Singapore Web Hosting
    • WordPress Hosting
    • Cheap Shared Hosting
    • Turbo Hosting
  • Reseller Hosting
    • Singapore Reseller Hosting
    • USA Reseller Hosting
  • Server
    • Singapore VPS
    • USA VPS
    • Germany VPS
    • Cheap VPS
  • Domain
    • Register Domain
    • Transfer Domain
    • Domain Promos
Client Area
Client Area

How to Set a Different Time Zone for a cPanel User (Cron Jobs & PHP)

by sajibe
February 24, 2025
cPanel

Introduction Many cPanel users face the issue where their hosted PHP scripts use a different time zone than the server’s default time. Additionally, cron jobs executed via cPanel follow the server time instead of the user’s preferred time zone. This can cause confusion and affect scheduling tasks such as automated backups, scheduled emails, or time-sensitive scripts.

If your server is located in the USA (e.g., Pacific Standard Time – PST), but your business operates in Bangladesh (Asia/Dhaka time zone), you might need to set a different time zone for your cPanel account.

In this guide, we will show you how to:

  • Change the time zone for a cPanel user
  • Ensure cron jobs use the correct time zone
  • Verify that the changes are applied correctly

Step 1: Set the Time Zone for PHP Scripts

Method 1: Use

If your website is running PHP, the easiest way to set the correct time zone is by modifying the .htaccess file inside your public_html directory.

Steps:

  1. Log in to cPanel.
  2. Open File Manager.
  3. Navigate to public_html/.
  4. Edit or create a .htaccess file.
  5. Add the following line:
    php_value date.timezone "Asia/Dhaka"
    
  6. Save the file and refresh your website.

To verify that the change is working, create a timezone.php file inside public_html and add this code:

<?php
    echo "Current Timezone: " . date_default_timezone_get() . "<br>";
    echo "Current Time: " . date('Y-m-d H:i:s');
?>

Visit https://yourdomain.com/timezone.php and check if it displays the correct time.

Method 2: Use

If .htaccess does not work, you can try setting the time zone inside the php.ini file.

Steps:

  1. In cPanel, go to File Manager.
  2. Inside public_html/, create or edit php.ini.
  3. Add the following line:
    date.timezone = "Asia/Dhaka"
    
  4. Save and test using timezone.php as shown above.

Step 2: Change Time Zone for Cron Jobs

By default, cron jobs in cPanel use the server’s time zone. To override this, add the “** variable** before running any cron job.

Steps:

  1. Log in to cPanel.
  2. Go to Cron Jobs.
  3. When adding a cron job, modify the command like this:
    TZ="Asia/Dhaka" php -q /home/your_cpanel_user/public_html/script.php
    
  4. Save the cron job.

✅ This ensures that the cron job runs in the correct time zone.

To verify, create a test cron job:

* * * * * TZ="Asia/Dhaka" date >> /home/your_cpanel_user/public_html/cron_log.txt

After a minute, check cron_log.txt to see if the time matches Asia/Dhaka.


Step 3: Set Time Zone for Terminal (SSH) & System Commands

If your cPanel account has Terminal (SSH) access, you can permanently change the time zone for your user.

Method 1: Temporary Change for Current Session

To set the time zone only for the current session, run:

export TZ="Asia/Dhaka"

To verify, run:

date

This change will reset after logout.

Method 2: Permanent Change for the User

  1. Open Terminal from cPanel.
  2. Edit the .bashrc file:
    nano ~/.bashrc
    
  3. Add this line at the bottom:
    export TZ="Asia/Dhaka"
    
  4. Save the file (CTRL + X, then Y, then ENTER).
  5. Apply the changes:
    source ~/.bashrc
    
  6. Verify:

    date

✅ Now, every time this user logs in, the time zone will automatically be set.

---

Final Verification & Testing

To ensure everything is working:
1. Check PHP time zone: Run `timezone.php`.
2. Verify cron jobs: Check `cron_log.txt` for correct timestamps.
3. Confirm SSH timezone: Run `date` in Terminal.
4. Check cron environment: Run:
env | grep TZ

✅ If it shows TZ=Asia/Dhaka, everything is configured correctly!


Conclusion

By following these steps, you can ensure that your PHP scripts, cron jobs, and SSH commands all use the correct time zone for your specific cPanel user, without affecting the entire WHM server.

If you’re managing multiple cPanel accounts on a WHM server, this method allows each user to have their own preferred time zone without requiring root access.

 

Tags: cPanel

Leave a Reply Cancel reply

You must be logged in to post a comment.

Recent Posts

  • How to Fix the “No NBD Device Passed to Disconnect – disconnect_nbd()” Error in Virtualizor
  • How to Fix WHMCS Database Crashed (Table Marked as Crashed) Error
  • Troubleshooting CloudLinux 9 Update Error: python3-rhn-check Dependency Issue
  • How to Set a Different Time Zone for a cPanel User (Cron Jobs & PHP)
  • Windows Vps

Recent Comments

No comments to show.

71-75 Shelton Street, Covent Garden, London
Company Number: 15697833

Payment Method
Company
  • About Us
  • News Feed
  • Affiliate Program
  • Knowledgebase
  • Client Area
  • Get in touch
Hosting
  • Singapore Hosting
  • Fastest WordPress Hosting
  • Turbo Hosting
  • Cheap Hosting
  • Reseller Hosting
  • VPS Hosting
Software Hosting
  • OpenCart Hosting
  • Magento Hosting
  • LiteCart Hosting
  • PrestaShop Hosting
  • Moodle Hosting
  • POS Hosting
Join Our Newsletter

We’ll send you news and offers.

Social Media
Facebook-f Linkedin X-twitter Whatsapp

Copyright © 2018 - 2025 PrenHost. All Rights Reserved

Report Abuse/Spam | Terms of Services | Refund Policy | Privacy Policy | Server Status