Description

The @time context query describes information around the time of the current viewing context. Use this context query to have your ad respond to the year, month, day, hour, etc.

Example Usage

Perhaps your ad is advertising the premiere of a new movie that hit theaters on December 18th, 2015 and you need to change the messaging to accurately reflect the relationship between the current date and the launch date. You could use the year, month and date context queries to achieve this effect as shown in the code example.

.release-date {
  /* Default */
	background: url(/assets/coming-december-18th.png);
  
  /* The week of */
  @time (month: december) and (date > 12) and (date < 17) {
    background: url(/assets/in-theaters-this-friday.png);
  }
  
  /* The day before */
  @time (month: december) and (date: 17) {
  	background: url(/assets/in-theaters-tomorrow.png);
  }
  
  /* Movie has launched */
  @time (month: december) and (date > 17), (year > 2015) {
  	background: url(/assets/in-theaters-now.png);
  }
}
var date = ad.get("timeDate"),
    month = ad.get("timeMonth"),
    year = ad.get("timeYear"),
    $element = $('img.release-date');

if (year <= 2015) {
  if (month === 'december' && date > 12 && date < 17) {
    
    /* It's the week of */
    $element.attr('src', '/assets/in-theaters-this-friday.png');
    
  } else if (month === 'december' && date === 17) {
    
    /* It's the day before */
    $element.attr('src', 'in-theaters-tomorrow.png');
    
  } else if (month === 'december' && date >= 18) {
    
    /* The movie has launched */
    $element.attr('src', 'in-theaters-now.png');
    
  } else {
   
    /* It's more than a week before */
    $element.attr('src', '/assets/coming-december-18th.png');
    
  }
} else {
  
  /* The movie has launched */
  $element.attr('src', 'in-theaters-now.png');
  
}

Available Features

Feature NameJavascript NameValueExample ValueDescription
yeartimeYearnumber2016The current year.
monthtimeMonthstringmarchThe current year.
month-numbertimeMonthNumbernumber3A number representing the current month in a 12 month calendar year. (e.g. March would be 3).
datetimeDatenumber22The calendar date of the current day of the month (e.g. 22 for March, 22nd).
daytimeDaystringwednesdayThe current day of the month.
day-numbertimerDayNumbernumber4A number representing the current day of the week beginning with Sunday and ending with Saturday (e.g. Wednesday would be 4).
hourtimeHournumber12The current hour of the current day (i.e 0-23)
minutetimeMinutenumber30The current minute of the current hour (i.e. 0-59).
secondtimeSecondnumber59The current second of the current minute (i.e. 0-59)
zonetimeZonenumber360The time difference between UTC time and local time, in minutes.