Web Analytics Made Easy -
StatCounter help with date/time - determining expiry date - CodingForum

Announcement

Collapse
No announcement yet.

help with date/time - determining expiry date

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • help with date/time - determining expiry date

    Hi guys,

    I was hoping for some help if possible?

    I need to find a way to mark entries in the MYSQL DB as expired once the expired date has passed.

    I plan on putting some code on the top of my front page so it can make this check whenever my site is loaded.

    example of data in expiry_date column
    2006-09-20 13:28:10

    I am using a function to get the current date (it is stored in $currentdatetime variable), it is oputputting the date as:
    2006-09-27 14:29:08

    Would I use '<' Less than ??

    PHP Code:
    // run the query
    $SQL " UPDATE postings SET status = 'expired' WHERE expiry_date < LESS THAN ?? $currentdatetime"
    Webmaster Tools | Webmaster Forums

  • #2
    As long as column expiry_date is of data type "date", "timestamp", or "datetime" then that works.

    Comment


    • #3
      Hi there,
      thanks for the reply

      So this should work?
      PHP Code:
      WHERE expiry_date <  $currentdatetime 
      Webmaster Tools | Webmaster Forums

      Comment


      • #4
        Whoo Hoo!! It works

        PHP Code:
        $SQL " UPDATE postings SET status = 'expired' WHERE expiry_date < '$currentdatetime3'"
        Thanks for the kick in the *** to try it myself... I swear, i just wont learn
        Webmaster Tools | Webmaster Forums

        Comment


        • #5
          MySQL has its own current date function, no need to get the current date from PHP and pass it into your query. Just use curdate(). That of course assumes your date column is a data type "date", "timestamp", or "datetime", which you haven't said one way or the other.

          Comment


          • #6
            I ma using my own function because the timezone difference.
            Webmaster Tools | Webmaster Forums

            Comment

            Working...
            X