Title: wordpress the_date() function
Last modified: August 19, 2016

---

# wordpress the_date() function

 *  [blazingtopics](https://wordpress.org/support/users/blazingtopics/)
 * (@blazingtopics)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/wordpress-the_date-function/)
 * I’m try to distinguish if the post is 7 days old. If it’s older than seven days,
   then display data1. If the post is not older than 7 days, then display data2.
   So far I have this:
 *     ```
       if (is_single() && ((int)the_date('d') != (int)date('j') ))
       	{
       		return $data2 ;
       	} else
       		{
       	    	return $data1 ;
       		}
       	}
       ```
   
 * Right now when I use this code the actual date gets printed on the post. Since
   today is the 19th, the number 19 is displayed. I’m not ever sure why it’s displaying
   the date on the page. Any ideas where I can go with this?

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

 *  Thread Starter [blazingtopics](https://wordpress.org/support/users/blazingtopics/)
 * (@blazingtopics)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/wordpress-the_date-function/#post-1351504)
 * ok I manage to work it out a bit. Now my problem is, again, with the_date() function.
   Is there anyway to use the_date() in a conditional statement without echoing 
   the date?
 *  [Alexandar Tzanov](https://wordpress.org/support/users/thetitan/)
 * (@thetitan)
 * [15 years, 4 months ago](https://wordpress.org/support/topic/wordpress-the_date-function/#post-1351759)
 * Look at [get_the_time](http://codex.wordpress.org/Function_Reference/get_the_time)
   via [http://wordpress.org/support/topic/adding-the_date-to-an-array](http://wordpress.org/support/topic/adding-the_date-to-an-array)

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

The topic ‘wordpress the_date() function’ is closed to new replies.

## Tags

 * [date](https://wordpress.org/support/topic-tag/date/)
 * [is_single](https://wordpress.org/support/topic-tag/is_single/)
 * [the_date](https://wordpress.org/support/topic-tag/the_date/)

 * 2 replies
 * 2 participants
 * Last reply from: [Alexandar Tzanov](https://wordpress.org/support/users/thetitan/)
 * Last activity: [15 years, 4 months ago](https://wordpress.org/support/topic/wordpress-the_date-function/#post-1351759)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
