# Determining if currently set time is in daylight savings or not

**URL:** <https://forum.arduino.cc/t/determining-if-currently-set-time-is-in-daylight-savings-or-not/357108>\
**Category:** Programming\
**Created:** [January 8, 2016, 12:14am UTC](https://forum.arduino.cc/t/determining-if-currently-set-time-is-in-daylight-savings-or-not/357108 "2016-01-08T00:14:56Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![odometer](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/odometer/32/1013044_2.png) [@odometer](https://forum.arduino.cc/u/odometer)\
**Post date:** [January 8, 2016, 2:35am UTC](https://forum.arduino.cc/t/determining-if-currently-set-time-is-in-daylight-savings-or-not/357108/4 "2016-01-08T02:35:21Z")

</div>

This seems to work:

```cpp
  // First, get the year:
  int yy = year - 2000;
  // yy should be e.g. 16 for AD 2016

  // Then calculate:
  int x = (yy + yy/4 + 2) % 7;

  // Then, if date/time is in the period from
  //  02:00:00 on day (14 - x) of March
  // through
  //  00:59:59 on day (7 - x) of November
  // then US Daylight Saving Time is in effect.

```

---

_[View the full topic](https://forum.arduino.cc/t/determining-if-currently-set-time-is-in-daylight-savings-or-not/357108)._
