Need helps with date and time in PHP/MySQL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rija

    Need helps with date and time in PHP/MySQL


    Hi folks,
    I need help regarding date and time comparison in PHP and MySQL
    My website is hosted in the USA (GMT - 8)
    And It is managed in Madagascar (GMT + 3)
    Want to consider DATE in Madagascar not in USA -
    MySQL CONVERT_TZ's function doesn't work

    So, how can I do the following:
    1. Today's visits
    $query = "SELECT count(*) FROM visits WHERE now() = date";

    2. Articles on the website appear only after 6 AM (GMT +3) compared to
    the date_publicatio n
    $query = "SELECT n_edition FROM $table WHERE NOW() >
    DATE_SUB(date_p ublication, INTERVAL 16 HOUR) ORDER BY n_edition DESC
    LIMIT 1" ;

    I don't know how to use DATE_ADD and DATE_SUB regarding the problem
    below.
    Notes that either visits.date and editions.date is recorded on the
    server GMT -8

    Any help could be appreciated

  • Jerry Stuckle

    #2
    Re: Need helps with date and time in PHP/MySQL

    rija wrote:
    Hi folks,
    I need help regarding date and time comparison in PHP and MySQL
    My website is hosted in the USA (GMT - 8)
    And It is managed in Madagascar (GMT + 3)
    Want to consider DATE in Madagascar not in USA -
    MySQL CONVERT_TZ's function doesn't work
    >
    So, how can I do the following:
    1. Today's visits
    $query = "SELECT count(*) FROM visits WHERE now() = date";
    >
    2. Articles on the website appear only after 6 AM (GMT +3) compared to
    the date_publicatio n
    $query = "SELECT n_edition FROM $table WHERE NOW() >
    DATE_SUB(date_p ublication, INTERVAL 16 HOUR) ORDER BY n_edition DESC
    LIMIT 1" ;
    >
    I don't know how to use DATE_ADD and DATE_SUB regarding the problem
    below.
    Notes that either visits.date and editions.date is recorded on the
    server GMT -8
    >
    Any help could be appreciated
    >
    Since you're asking about MySQL operations and not PHP, might I suggest
    you ask in comp.database.m ysql - where all the MySQL users hang out?

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    Working...