/    Sign up×
Community /Pin to ProfileBookmark

addind hours in php

User send some request and that request is solved by admin within 5 hours.

[B]Requirements: [/B]

  • 1.

    Adding 5 hours from the current time

  • 2.

    Added hours within the office time 10Am to 6 Pm and except holiday

  • [B]For Example [/B]:

  • 3.

    If user giving request at 11Am means add 5hours and admin will give response within 4Pm.

  • 4.

    If user giving request at 2pm means add 5 hours and admin will give

    response within next day 11Am becuse office time ends in 6pm.

  • 5.

    If user giving request in satuarday 5pm means add 5 hours admin will give

  • response within monday 2 Pm because office time ends in 6pm and

    to post a comment
    PHP

    3 Comments(s)

    Copy linkTweet thisAlerts:
    @toicontienApr 14.2009 — If you are using Linux for an operating system, you can use the strtotime function to parse a string date into an Unix time stamp. Then it's just a matter of adding 4 * 60 * 60 seconds to the time stamp.
    [CODE]$date = strtotime( $_GET['date'] );
    $date += 4 * 60 * 60; // or += 4 * 3600 or += 14400
    $fdate = strftime('date format here', $date);

    echo $fdate;[/CODE]
    Copy linkTweet thisAlerts:
    @MindzaiApr 14.2009 — If you are using Linux for an operating system, you can use the strtotime function to parse a string date into an Unix time stamp. Then it's just a matter of adding 4 * 60 * 60 seconds to the time stamp.
    [CODE]$date = strtotime( $_GET['date'] );
    $date += 4 * 60 * 60; // or += 4 * 3600 or += 14400
    $fdate = strftime('date format here', $date);

    echo $fdate;[/CODE]
    [/QUOTE]


    Or just:

    [code=php]$date = strtotime($_GET['date'] . ' +5 hours');[/code]
    Copy linkTweet thisAlerts:
    @SodbusterApr 15.2009 — I think this will meet the [B]Requirements[/B]:[code=php]$start = '2009-04-14 15:00:00';
    $holidays = array('2009-05-25', '2009-07-31');

    $start_ts = strtotime($start);
    $closing_ts = strtotime(date('Y-m-d ', $start_ts) . '18:00:00');
    $answer_ts = strtotime('+5 hours', $start_ts);
    if ($answer_ts > $closing_ts) {
    $diff_ts = $answer_ts - $closing_ts;
    do {
    $start_ts = strtotime('tomorrow 10:00:00', $start_ts);
    } while ((date('N', $start_ts) == 7) || in_array(date('Y-m-d', $start_ts), $holidays));
    $answer_ts = $start_ts + $diff_ts;
    }

    echo date('Y-m-d H:i:s', $answer_ts);[/code]
    As far as I know [I]strtotime()[/I] has always worked on both Windows and
    ×

    Success!

    Help @Ashokkumar spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.17,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...