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

  • SEARCH
  • Home
  • 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 6255289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T14:20:19+00:00 2026-05-24T14:20:19+00:00

I created a small script to display the time( UTC-+3.5 ). The problem is

  • 0

I created a small script to display the time(UTC-+3.5). The problem is there that changes GMT(+4.5, +3.5) in Iran every six months in year, and changes Time is pulled back and forth (Daylight Saving)
How i set yourself clock with change GMT in iran? what do i do? (now GMT in iran is +4.5)

EXAMPLE: my code-jsfiddle

var int = self.setInterval("clock()", 1000);

function clock() {
    var d = calcTime('+4.5')
    var t = d.toLocaleTimeString();
    document.getElementById("clock").innerHTML = t;
}

function calcTime(offset) {
    d = new Date();
    utc = d.getTime() + (d.getTimezoneOffset() * 60000);
    nd = new Date(utc + (3600000 * offset));

    return nd;
}

With respect

  • 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-05-24T14:20:20+00:00Added an answer on May 24, 2026 at 2:20 pm

    Fiddle Example

    <script type="text/javascript">
    var int = self.setInterval("clock()", 1000);
    
    function clock() {
        var d = calcTime('+4.5')
        var t = d.toLocaleTimeString();
        document.getElementById("clock").innerHTML = t;
    }
    
    function calcTime(offset) {
        d = new Date();
        ds = new Date(); // new Daylight Savings Time object
        ds.setMonth(9); // Set month to september
        ds.setDate(21); // set day to 21st
        if(d > ds){ // if current date is past the daylight savings date minus one from the offset
            offset = eval(offset - 1);
        }
        utc = d.getTime() + (d.getTimezoneOffset() * 60000);
        nd = new Date(utc + (3600000 * offset));
    
        return nd;
    }
    </script>
    
    <b id="clock"></b>
    

    This works. It will check if the date is currently past September 21st and if it is it will -4.5 from GMT otherwise 3.5

    it is not the cleanest code i’ve ever written, I just modified yours. however you can see how it is done now.

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

Sidebar

Related Questions

I've created a small Bash script that does a MySQL data dump. Because the
I created a small lightbox script, the script itself works fine but the problem
I have created a small php script locally that runs a java application in
I've created a small script that opens a text document, increments a number each
I've created a small python script to toggle between two files I'm using for
I have created a small flash CS4 project that has a few custom components
I've created a small PowerShell script to remove a Autodesk application. However, PowerShell doesn't
I created a small shell script which logs all of it's input to a
I've created a small script to test out getting the basename of all files
I'm creating a system that turns a small script into a dll. I'm encountering

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.