Replies

Nov 7, 2018 7 years ago
Jeheace
the snuggle monster
User Avatar

Is there a way to change images on the pet profile based on the time of day?

The general idea is as follows: If time is greater than x but less than y, use image0, else use image1 Like... if time is from 8pm to 8am, use one image, but from 8:01am to 7:59pm use the other.

Please let me know if ya'll have any ideas on trying to execute this.

Nov 8, 2018 7 years ago
Sorcerer
is a worthy opponent
User Avatar
Forsake

I've used this PHP to randomize my profile images before, you'd need to add a little extra logic for the time windows but the base is there. That's all I can think of.

Nov 8, 2018 7 years ago
Jeheace
the snuggle monster
User Avatar

Thank you ^-^ It's some where to start! I'll update as I figure things out.

Nov 8, 2018 7 years ago
Sorcerer
is a worthy opponent
User Avatar
Forsake

Working proof of concept.

  1. It's in 24hr time (from 00 to 23).
  2. Need to set timezone to match Subeta.
  3. One image before 20:00 and one after.
  4. I can't tell how it picks which image though, supposedly it's to do with the file's creation time? With two images I guess it doesn't matter, just switch the numbers if it's picking the wrong one :P

Replace this if (count($fileList) > 0) { $imageNumber = time() % count($fileList); $img = $folder.$fileList[$imageNumber]; }With this if (count($fileList) > 0) { if (date('H') < 20) { $img = $folder.$fileList[0]; } else { $img = $folder.$fileList[1]; } } And you also need this right after the "end configuration" part. date_default_timezone_set('America/Detroit');

Please log in to reply to this topic.