Simple math I'm sure, Need help

Discussion in 'Programming' started by unitedlocalbands, Sep 19, 2007.

  1. #1
    I have been trying to get this to just subtract 7 hours from the timestamp that is returned from the query.

    I can get it to subtract 7 days from the date but I cant figure out what I need to make it subtract 7 hours from the time.



    
    <cfset localdate = #date_time#>
    <cfset localtime = (#date_time# - 7)>
    
    
    #LSDateFormat("#localdate#", "mmm-dd-yyyy")#  
    
    #LSTimeFormat("#localtime#", "hh:mm:sstt")#
    
    
    Code (markup):
    Thanks,
     
    unitedlocalbands, Sep 19, 2007 IP
  2. alarik

    alarik Active Member

    Messages:
    382
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    I bumped into the same problems a few months ago but I fixed it somehow else, please review www.php.net for date() function, you will find other ways
     
    alarik, Sep 19, 2007 IP
  3. unitedlocalbands

    unitedlocalbands Well-Known Member

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #3
    Thanks for the encouragement.

    I'm not familiar with php. I do all my server side script with cold fusion.

    It seems like such a simple thing to do but I swear i have been searching and searching all night and I cant find a single Coldfusion forum that has addressed this simple little math problem.

    Thanks Again,
     
    unitedlocalbands, Sep 19, 2007 IP
  4. alarik

    alarik Active Member

    Messages:
    382
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #4
    <?php
    $lastWeek = time() - (7 * 24 * 60 * 60);
    // 7 days; 24 hours; 60 mins; 60secs
    echo 'Now: '. date('Y-m-d') ."\n";
    echo 'Last Week: '. date('Y-m-d', $lastWeek) ."\n";
    // or using strtotime():
    echo 'Last Week: '. date('Y-m-d', strtotime('-1 week')) ."\n";
    ?>

    math sucks, i know, but this has nothing 2 do with math.you owe me a bear;)
     
    alarik, Sep 19, 2007 IP
  5. unitedlocalbands

    unitedlocalbands Well-Known Member

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #5
    What is your brand and where would you like it sent?

    I'll buy you as many beers as you can drink if you can write that in coldfusion.

    :cool:

    Reason being my server only supports coldfusion.
     
    unitedlocalbands, Sep 19, 2007 IP
  6. alarik

    alarik Active Member

    Messages:
    382
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #6
    :)) sorry I don't know coldfusion but I suggest u just forget about it and try php :).
    I drink carlsberg
     
    alarik, Sep 19, 2007 IP
  7. unitedlocalbands

    unitedlocalbands Well-Known Member

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #7
    Good beer...

    I used to deliver beer. Best Job I ever had!
     
    unitedlocalbands, Sep 19, 2007 IP
  8. Jamie18

    Jamie18 Peon

    Messages:
    201
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #8
    i would look through the coldfusion documentation at all the different date functions... i think dateadd might work for you here..

    <cfset localdate = #date_time#>
    <cfset localtime = dateadd("d", -7, "#date_time#")>

    that may or may not work.. i'm just throwing it out there
     
    Jamie18, Sep 19, 2007 IP
  9. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Jamie18 is spot on. Just use "h" (for hour) instead.

    
    <cfset localtime = dateadd("h", -7, date_time)>
    
    Code (markup):
     
    cfStarlight, Sep 19, 2007 IP
  10. unitedlocalbands

    unitedlocalbands Well-Known Member

    Messages:
    246
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    128
    #10
    I knew it was simply, I didnt have all the parts in the right areas. I did a lot of searching all night but I think my brain was fried.

    Thanks, we are on our way to globalization!
     
    unitedlocalbands, Sep 19, 2007 IP