SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    328
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    How do I set time shedule for a post with php

    Hi,

    I'm seeking recommendation of keywords to search for a method that I can set my message to show up e.g. 08:00:00 tomorrow.

    I've no idea what does this thing call and my searching on google for several days yield nothing close to what I'm trying to achieve.

    I'm using a .aspx website with a feature like this, but I want to know if I can do it with php.

    Thanks
    Ket

  2. #2
    SitePoint Enthusiast
    Join Date
    Sep 2009
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If I understand you correctly you want a message to display at a certain time?

    A simple if condition would do it, just compare the current time() with the time to show the message.

  3. #3
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    328
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by the182guy View Post
    A simple if condition would do it, just compare the current time() with the time to show the message.
    @the182guy

    Thanks, that's interesting.

    Can you give me a hint?

    Ket

  4. #4
    Twitter: @AnthonySterling silver trophy AnthonySterling's Avatar
    Join Date
    Apr 2008
    Location
    North-East, UK.
    Posts
    6,111
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    A quick example, but probably not what you're looking for as this will only be triggered for 1 second.

    PHP Code:
    <?php
    $triggerTime 
    strtotime('tomorrow 14:00');

    if(
    time() === $triggerTime){
      
    #show/do stuff
    }
    More likely, you'll be looking for something like...

    PHP Code:
    <?php
    $triggerTime 
    strtotime('tomorrow 14:00');

    /* "at" trigger time */
    if(time() === $triggerTime){
      
    #show/do stuff
    }

    /* "after" trigger time */
    if(time() > $triggerTime){
      
    #show/do stuff
    }

    /* "before" trigger time */
    if(time() < $triggerTime){
      
    #show/do stuff
    }
    @AnthonySterling: I'm a PHP developer, a consultant for oopnorth.com and the organiser of @phpne, a PHP User Group covering the North-East of England.

  5. #5
    SitePoint Addict ketting00's Avatar
    Join Date
    Jul 2011
    Posts
    328
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Thanks AnthonySterling,

    I'm testing the codes.

    Ket


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •