Title: Simple PHP Date   Math question
Last modified: August 20, 2016

---

# Simple PHP Date Math question

 *  [petezarustica](https://wordpress.org/support/users/petezarustica/)
 * (@petezarustica)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/simple-php-date-math-question/)
 * Hi everybody,
 * I want to write someone’s age and I want it to be dynamic. So let’s say Julie
   is 20 years old. Then Julie is (this year – 1981) years old.
 * I manage to do that calculation on WP with the following code:
 *     ```
       <?php $prodid = 2011;
       $second_number = 1991;
       $sum_total = $prodid - $second_number;
       print ($sum_total);
       ?>
       ```
   
 * But it’s still not dynamic – I’d like the 2011 to be <?php the_time(‘Y’); ?> 
   but it’s doesn’t work!!! ^
    Can someone help me with this detail?
 * [s]

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

 *  [Andrei Olsen](https://wordpress.org/support/users/nebulus/)
 * (@nebulus)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/simple-php-date-math-question/#post-2130841)
 * `$prodid = strftime('%Y');`
 * [http://php.net/manual/en/function.strftime.php](http://php.net/manual/en/function.strftime.php)
 * or better yet:
    [http://www.php.net/manual/en/function.idate.php](http://www.php.net/manual/en/function.idate.php)
 * `print(idate('Y')-$second_number);`
 *  Thread Starter [petezarustica](https://wordpress.org/support/users/petezarustica/)
 * (@petezarustica)
 * [14 years, 11 months ago](https://wordpress.org/support/topic/simple-php-date-math-question/#post-2130861)
 * Thanks Andrei! 🙂

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

The topic ‘Simple PHP Date Math question’ is closed to new replies.

## Tags

 * [Math](https://wordpress.org/support/topic-tag/math/)
 * [minus](https://wordpress.org/support/topic-tag/minus/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [print](https://wordpress.org/support/topic-tag/print/)
 * [simple](https://wordpress.org/support/topic-tag/simple/)
 * [year](https://wordpress.org/support/topic-tag/year/)

 * 2 replies
 * 2 participants
 * Last reply from: [petezarustica](https://wordpress.org/support/users/petezarustica/)
 * Last activity: [14 years, 11 months ago](https://wordpress.org/support/topic/simple-php-date-math-question/#post-2130861)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
