SitePoint Sponsor

User Tag List

Results 1 to 2 of 2

Thread: Curdate()

Threaded View

  1. #1
    SitePoint Enthusiast DaDeViL's Avatar
    Join Date
    Aug 2003
    0 Post(s)
    0 Thread(s)


    PHP Code:
    $query "SELECT CURDATE() AS today,
                MONTH(CURDATE()) AS month,
                YEAR(CURDATE()) AS year;"
    $result db_get($query);
    $today          mysql_result($result,0today);
    $today_month    mysql_result($result,0month);
    $today_year     mysql_result($result,0year); 
    here is the problem:
    I am trying to modify a calender script i found on hotscripts. Because i wanted free MySQL hosting i had to get an account with a host in the UK. Well, the calender script uses the servertime to function, so the time is always 6 hours ahead of where i am (eastern time zone) thus, it changes dates at 6 pm eastern time, instead of midnight like a normal calender . Well, to fix this i simply have to subtract 6 hours, here is the script i wrote:

    PHP Code:
    $hour -= 6;  //(assuming i already found the $hour variable earlier)
    if($hour 0){
    $today == 1){
    $today_month 0){
    when i do it this way, the calender stops working correctly, i think mainly because the date format that $today must come in is different. I must output $today in this format yyyy-mm-dd .

    according to the code waay up top, i cant change the value of $today that easily since it comes out in the format yyyy-mm-dd so i need a way to get $today out in a diff variable DAY(CURDATE()) AS day will that work?

    also when i do change the value of the day, month and year, i need to put it back into the format yyyy-mm-dd as mentioned can i do this? like this? $today = "$today_year-$today_month-$day";

    Last edited by DaDeViL; Aug 7, 2003 at 18:52.


Posting Permissions

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