Title: Loop using the current year
Last modified: September 15, 2019

---

# Loop using the current year

 *  [iantresman](https://wordpress.org/support/users/iantresman/)
 * (@iantresman)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/loop-using-the-current-year/)
 * [today format=Y] returns the current year. I’d like to use the value in a loop(
   and using [calc]), but I can’t figure how. Is it possible:
    - 2019 It is 5 years since 2014
    - 2018 It is 4 years since 2014
    - 2017 It is 3 years since 2014
    - 2016 It is 2 years since 2014
    - 2015 It is 1 years since 2014
 *  -  This topic was modified 6 years, 8 months ago by [iantresman](https://wordpress.org/support/users/iantresman/).
    -  This topic was modified 6 years, 8 months ago by [iantresman](https://wordpress.org/support/users/iantresman/).

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [dmunaretto](https://wordpress.org/support/users/dmunaretto/)
 * (@dmunaretto)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/loop-using-the-current-year/#post-11946238)
 * Not sure how you want to use it within a loop but maybe this will help – this
   returns the current year based on the date minus 2014:
 * [set variable1]20[today format=y][/set]
    [get variable1] It is [calc][get variable1]–
   2014[/calc] years since 2014.
 * [today format=y] has the Y2K bug apparently 😉 it only returns “19” – obviously
   you can also take the 20 out of both spots (20[today… and 2014) and have it subtract
   19 – 14 = 5
 * If you are looking to use in a loop somehow, post a bit of additional info –
 * Hope this helps
 *  Thread Starter [iantresman](https://wordpress.org/support/users/iantresman/)
 * (@iantresman)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/loop-using-the-current-year/#post-11946380)
 * That’s it, thank you! Had to tweak it slightly.
 * [today format=y] produces 19,
    [today format=Y] produces 2019
 * So the example script now reads:
 *     ```
       [set myyear][today format=Y][/set]
       Now is: [get myyear]
       It is [calc]myyear-2014[/calc] years since 2014. 
       ```
   
    -  This reply was modified 6 years, 8 months ago by [iantresman](https://wordpress.org/support/users/iantresman/).
 *  [dmunaretto](https://wordpress.org/support/users/dmunaretto/)
 * (@dmunaretto)
 * [6 years, 8 months ago](https://wordpress.org/support/topic/loop-using-the-current-year/#post-11946539)
 * Perfect – glad it helped!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Loop using the current year’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [dmunaretto](https://wordpress.org/support/users/dmunaretto/)
 * Last activity: [6 years, 8 months ago](https://wordpress.org/support/topic/loop-using-the-current-year/#post-11946539)
 * Status: not resolved