latest stable versions: v150827 (changelog)

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Can you time the display based on clock time?

Home Forums Community Forum Can you time the display based on clock time?

This topic contains 10 replies, has 3 voices. Last updated by  Eduan 4 years, 2 months ago.

Topic Author Topic
Posted: Friday Oct 19th, 2012 at 5:09 pm #29067
cassel
Username: cassel

I am planning an activity for a specific event during which time i would like to display tutorials/videos for a short period of time over a 24 hour span. For example, i would like tutorial 1 to display from 12 to 1pm, then tutorial from 1 to 2pm and so on, with no ccap limitation. Since i dont want to be sitting at the computer on the of the hour for 24 hours straight, is there a way to use a conditional of some kind based on the actual time of day and NOT based on registration time like in dripping content?

It might sound odd, but it is a great traffic generator to have such an activity in as part of a particular event.

List Of Topic Replies

Viewing 10 replies - 1 through 10 (of 10 total)
Author Replies
Author Replies
Posted: Saturday Oct 20th, 2012 at 1:01 am #29108
Raam Dev
Username: Raam
Staff Member

Hi cassel,

You can use the PHP date() function to determine the current time of the day and base your conditionals on that. Here’s an example of how the date() function can be used to determine the current time of day.

Posted: Saturday Oct 20th, 2012 at 6:55 am #29116
cassel
Username: cassel

Oh, that might be good. Better study now.
Thanks.

———–

Ok i tried this:
if (date(‘H’) > 7) && (date(‘H’) < 8) {
it is now between 7 and 8
}

and i only get the actual text of the code to appear and not what it is supposed to. What did i miss?

  • This reply was modified 4 years, 2 months ago by  cassel.
Posted: Saturday Oct 20th, 2012 at 9:35 am #29142
Eduan
Username: Eduan
Moderator

Hello cassel,

I believe it has to do with the parentheses, and the fact that you’re using smart quotes, not normal quotes. Try this instead:

if (date('H') > 7 && date('H') < 8) {
	it is now between 7 and 8
}

Hope this helps. :)

Posted: Saturday Oct 20th, 2012 at 9:59 am #29145
cassel
Username: cassel

Nope, it still displays the text of the code. :(

Posted: Saturday Oct 20th, 2012 at 10:24 am #29146
Eduan
Username: Eduan
Moderator

Hmm, is it between PHP tags? So is it like this?:

<?php
if (date('H') > 7 && date('H') < 8) {
	it is now between 7 and 8
}
?>

I suppose you already have a PHP execution plugin so I don’t think that’s the problem.

– Eduan

Posted: Saturday Oct 20th, 2012 at 10:59 am #29150
cassel
Username: cassel

Dont laugh at me, my php syntax is poor, and i DID forget the <?php part *shakes head* I knew i was missing something!

However, i get this error:
Parse error: syntax error, unexpected T_STRING in /home/creas1/public_html/scrapbookcampus.com/wp-content/themes/headway-2013/library/core/functions.php(90) : eval()'d code on line 3

Posted: Sunday Oct 21st, 2012 at 10:42 am #29208
cassel
Username: cassel

Ok i got my syntax fixed. Next question: how do i know that the time that i set is for the correct time zone? If i make a tutorial to appear at 10am my time, will it appear at 10am YOUR time if you are somewhere else? Either way is fine, but i would like to know.

Posted: Sunday Oct 21st, 2012 at 10:52 am #29209
Eduan
Username: Eduan
Moderator

Check this PHP documentation:
http://php.net/manual/en/function.date.php

Search for “Timezone”, and then read the documentation there, haven’t really messed with this, so not sure exactly how it would work, regarding timezones. :/

– Eduan

Posted: Sunday Oct 21st, 2012 at 5:19 pm #29219
cassel
Username: cassel

I didn’t bother with the timezone as i figured out the time is based on the server’s timezone. I just have to make the conversion and it is only 2 hours. No biggie. I also added a date condition, so it will only display on the specific days, while i can configure it earlier :)

For anyone interested, here is the code:

<?php
if (date('H') == 12 && date("Ymd") == 20121021) {
  echo 'This will show at noon on the Nov 21st, 2012';
}
?>

Interestingly, the next day, the time seems to be based on GMT instead (3 hours later) while yesterday it was displaying the server time (2 hours earlier). Just odd!

  • This reply was modified 4 years, 2 months ago by  cassel.
Posted: Monday Oct 22nd, 2012 at 12:36 pm #29272
Eduan
Username: Eduan
Moderator

That’s strange behavior. lol

Glad you solved it though. :)

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

This topic is closed to new replies. Topics with no replies for 2 weeks are closed automatically.

Old Forums (READ-ONLY): The community now lives at WP Sharks™. If you have an s2Member® Pro question, please use our new Support System.

Contacting s2Member: Please use our Support Center for bug reports, pre-sale questions & technical assistance.