当前位置: 首页>>代码示例>>PHP>>正文


PHP TimeDate类代码示例

本文整理汇总了PHP中TimeDate的典型用法代码示例。如果您正苦于以下问题:PHP TimeDate类的具体用法?PHP TimeDate怎么用?PHP TimeDate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了TimeDate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setup

 public function setup()
 {
     global $current_user;
     $current_user = SugarTestUserUtilities::createAnonymousUser();
     //for the purpose of this test, we need to create a campaign and relate it to a campaign tracker object
     //create campaign
     $c = new Campaign();
     $c->name = 'CT test ' . time();
     $c->campaign_type = 'Email';
     $c->status = 'Active';
     $timeDate = new TimeDate();
     $c->end_date = $timeDate->to_display_date(date('Y') + 1 . '-01-01');
     $c->assigned_id = $current_user->id;
     $c->team_id = '1';
     $c->team_set_id = '1';
     $c->save();
     $this->campaign = $c;
     //create campaign tracker
     $ct = new CampaignTracker();
     $ct->tracker_name = 'CampaignTrackerTest' . time();
     $ct->tracker_url = 'sugarcrm.com';
     $ct->campaign_id = $this->campaign->id;
     $ct->save();
     $this->campaign_tracker = $ct;
 }
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:25,代码来源:CampaignTrackersTest.php

示例2: CustomScheduler

function CustomScheduler()
{
    global $sugar_config, $db;
    $timeDate = new TimeDate();
    $timeDateNow = $timeDate->getNow(true)->asDb();
    $days_offset = 15;
    $GLOBALS['log']->fatal("Checking Opportunities...");
    $query = "select opportunities.id from opportunities\n\twhere opportunities.sales_stage != 'Closed Won'\n\tand DATEDIFF(opportunities.date_modified,'" . $timeDateNow . "') < " . $days_offset . "\n\tand !opportunities.deleted";
    $GLOBALS['log']->fatal("Query: " . $query);
    $res = $db->query($query, true, 'Error: ');
    while ($row = $db->fetchByAssoc($res)) {
        $opportunity = new Opportunity();
        if (!is_null($opportunity->retrieve($row['id']))) {
            $user = new User();
            if (!is_null($user->retrieve($opportunity->assigned_user_id))) {
                $emailsTo = array();
                $emailSubject = "Opportunity Alert";
                $emailBody = "The following Opportunity has " . $days_offset . " days without changes.<br /><br />\n\t\t\t\tName: " . $opportunity->name . "<br />\n\t\t\t\tAccount: " . $opportunity->account_name . "<br />\n\t\t\t\tAmount: " . $opportunity->amount . "<br />\n\t\t\t\tSales Stage: " . $opportunity->sales_stage . "<br />\n\t\t\t\tDate Close: " . $opportunity->date_closed . "<br /><br />\n\t\t\t\tYou can see the opportunity here:<br />\n\t\t\t\t<a href=\"" . $sugar_config['site_url'] . "/index.php?module=Opportunities&action=DetailView&record=" . $opportunity->id . "\">" . $opportunity->name . "</a>";
                $emailsTo[] = $user->email1;
                SendEmail($emailsTo, $emailSubject, $emailBody);
            }
        }
    }
    $GLOBALS['log']->fatal("Opportunities checked");
    return true;
}
开发者ID:julieth756,项目名称:SugarCRMSchedulers,代码行数:26,代码来源:CustomSchedulers.php

示例3: CreateTaskAndCallForNewOpportunity

 function CreateTaskAndCallForNewOpportunity($bean)
 {
     $timeDate = new TimeDate();
     if (empty($bean->fetched_row['id'])) {
         $task = new Task();
         $task->name = "Send Proposal";
         $task->priority = "High";
         $task->status = "Not Started";
         $task->date_due = $timeDate->getNow(true)->modify("+1 days")->asDb();
         $task->parent_type = "Opportunities";
         $task->parent_id = $bean->id;
         $task->assigned_user_id = $bean->assigned_user_id;
         $task->save();
         $call = new Call();
         $call->name = "Follow up";
         $call->direction = "Outbound";
         $call->status = "Planned";
         $call->duration_hours = 0;
         $call->duration_minutes = 15;
         $call->date_start = $timeDate->getNow(true)->modify("+2 days")->asDb();
         $call->parent_type = "Opportunities";
         $call->parent_id = $bean->id;
         $call->assigned_user_id = $bean->assigned_user_id;
         $call->save();
     }
 }
开发者ID:julieth756,项目名称:SugarCRMLogicHooks,代码行数:26,代码来源:OpportunitiesHooks.php

示例4: ping

 public function ping($api, $args)
 {
     if (isset($args['sub_method']) && $args['sub_method'] == 'whattimeisit') {
         require_once 'include/SugarDateTime.php';
         $dt = new SugarDateTime();
         $td = new TimeDate();
         return $td->asIso($dt);
     }
     // Just a normal ping request
     return 'pong';
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:11,代码来源:PingApi.php

示例5: assignResult

 /**
  * {@inheritdoc}
  */
 protected function assignResult($event)
 {
     $this->conversation = $event['conversation_to'];
     $this->type = $event['event_type'];
     $this->timestamp = TimeDate::fromMysql($event['timestamp']);
     $this->status = $event['status'];
 }
开发者ID:blast007,项目名称:bzion,代码行数:10,代码来源:AbstractMessage.php

示例6: setUp

 public function setUp()
 {
     $this->scheduler = new TestScheduler(false);
     $GLOBALS['timedate'] = $this->timedate = TimeDate::getInstance();
     $this->timedate->allow_cache = true;
     $this->now = $this->timedate->getNow();
 }
开发者ID:sunmo,项目名称:snowlotus,代码行数:7,代码来源:SchedulerTest.php

示例7: testGetTimeDate

 public function testGetTimeDate()
 {
     global $current_user;
     $this->_setPrefs("Y-m-d", "H:i", "GMT");
     $f = $this->time_date->get_date_time_format();
     $this->assertEquals("Y-m-d H:i", $f);
     $f = $this->time_date->get_date_time_format(true);
     $this->assertEquals("Y-m-d H:i", $f);
     $f = $this->time_date->get_date_time_format(false);
     $this->assertEquals("Y-m-d H:i", $f);
     $f = $this->time_date->get_date_time_format(null);
     $this->assertEquals("Y-m-d H:i", $f);
     $f = $this->time_date->get_date_time_format(true, null);
     $this->assertEquals("Y-m-d H:i", $f);
     $f = $this->time_date->get_date_time_format(false, null);
     $this->assertEquals("Y-m-d H:i", $f);
     $f = $this->time_date->get_date_time_format(null, null);
     $this->assertEquals("Y-m-d H:i", $f);
     $f = $this->time_date->get_date_time_format(true, $current_user);
     $this->assertEquals("Y-m-d H:i", $f);
     $f = $this->time_date->get_date_time_format(false, $current_user);
     $this->assertEquals("Y-m-d H:i", $f);
     $f = $this->time_date->get_date_time_format(null, $current_user);
     $this->assertEquals("Y-m-d H:i", $f);
     $f = $this->time_date->get_date_time_format($current_user);
     $this->assertEquals("Y-m-d H:i", $f);
     $f = $this->time_date->get_date_time_format($current_user);
     $this->assertEquals("Y-m-d H:i", $f);
     $f = $this->time_date->get_date_time_format($current_user);
     $this->assertEquals("Y-m-d H:i", $f);
 }
开发者ID:nickpro,项目名称:sugarcrm_dev,代码行数:31,代码来源:TimeDateTest.php

示例8: getOrderBy

 /**
  * checks the request for the order by and if that is not set then it checks the session for it
  *
  * @return array containing the keys orderBy => field being ordered off of and sortOrder => the sort order of that field
  */
 function getOrderBy($orderBy = '', $direction = '')
 {
     if (!empty($orderBy) || !empty($_REQUEST[$this->var_order_by])) {
         if (!empty($_REQUEST[$this->var_order_by])) {
             $direction = 'ASC';
             $orderBy = $_REQUEST[$this->var_order_by];
             if (!empty($_REQUEST['lvso']) && (empty($_SESSION['lvd']['last_ob']) || strcmp($orderBy, $_SESSION['lvd']['last_ob']) == 0)) {
                 $direction = $_REQUEST['lvso'];
                 $trackerManager = TrackerManager::getInstance();
                 if ($monitor = $trackerManager->getMonitor('tracker')) {
                     $monitor->setValue('module_name', $GLOBALS['module']);
                     $monitor->setValue('item_summary', "lvso=" . $direction . "&" . $this->var_order_by . "=" . $_REQUEST[$this->var_order_by]);
                     $monitor->setValue('action', 'listview');
                     $monitor->setValue('user_id', $GLOBALS['current_user']->id);
                     $monitor->setValue('date_modified', TimeDate::getInstance()->nowDb());
                     $monitor->save();
                 }
             }
         }
         $_SESSION[$this->var_order_by] = array('orderBy' => $orderBy, 'direction' => $direction);
         $_SESSION['lvd']['last_ob'] = $orderBy;
     } else {
         if (!empty($_SESSION[$this->var_order_by])) {
             $orderBy = $_SESSION[$this->var_order_by]['orderBy'];
             $direction = $_SESSION[$this->var_order_by]['direction'];
         } else {
             $orderBy = 'date_entered';
             $direction = 'DESC';
         }
     }
     return array('orderBy' => $orderBy, 'sortOrder' => $direction);
 }
开发者ID:dgrudinin,项目名称:Field-Level-Access-Control-for-SugarCRM,代码行数:37,代码来源:ListViewData.php

示例9: ejecutar

 public function ejecutar($focus, $string_parametros)
 {
     $this->procesar_parametros($string_parametros);
     $alarma = loadBean('gcoop_alarmas');
     $alarma->parent_type = $focus->module_dir;
     $alarma->parent_id = $focus->id;
     $alarma->destinatario = $this->destinatario;
     $alarma->notificacion = $this->notificacion;
     $alarma->parametro = $this->parametro;
     $alarma->valor = $this->valor;
     #sumarle dias no fin de semana!
     $fecha = new DateTime();
     $dia = new DateInterval('P1D');
     while ($this->cantidad_dias > 0) {
         $fecha->add($dia);
         if ($fecha->format('N') < 6) {
             $this->cantidad_dias -= 1;
         }
     }
     $timedate = TimeDate::getInstance();
     $alarma->fecha_disparo = $timedate->asDb($fecha);
     $alarma->save();
     if (method_exists($focus, 'notificar')) {
         $focus->notificar("Se creó alarama con fecha de disparo {$alarma->fecha_disparo}", 'Alarma');
     }
 }
开发者ID:dinhquyet92,项目名称:sugarcrm_advanced_workflows,代码行数:26,代码来源:CrearAlarma.php

示例10: generateItem

    protected function generateItem($item)
    {
        $name = !empty($item['name_value_list']['name']['value']) ? htmlentities($item['name_value_list']['name']['value']) : '';
        $url = $GLOBALS['sugar_config']['site_url'] . htmlentities('/index.php?module=' . $item['module_name'] . '&action=DetailView&record=' . $item['id']);
        $date = TimeDate::httpTime(TimeDate::getInstance()->fromDb($item['name_value_list']['date_modified']['value'])->getTimestamp());
        $description = '';
        $displayFieldNames = true;
        if (count($item['name_value_list']) == 2 && isset($item['name_value_list']['name'])) {
            $displayFieldNames = false;
        }
        foreach ($item['name_value_list'] as $k => $v) {
            if ($k == 'name' || $k == 'date_modified') {
                continue;
            }
            if ($displayFieldNames) {
                $description .= '<b>' . htmlentities($k) . ':<b>&nbsp;';
            }
            $description .= htmlentities($v['value']) . "<br>";
        }
        echo <<<EORSS
    <item>
        <title>{$name}</title>
        <link>{$url}</link>
        <description><![CDATA[{$description}]]></description>
        <pubDate>{$date} GMT</pubDate>
        <guid>{$item['id']}</guid>
    </item>

EORSS;
    }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:30,代码来源:SugarRestRSS.php

示例11: run

 /**
  * This method implements the run function of RunnableSchedulerJob and handles processing a SchedulersJob
  *
  * @param Mixed $data parameter passed in from the job_queue.data column when a SchedulerJob is run
  * @return bool true on success, false on error
  */
 public function run($data)
 {
     global $app_strings, $language;
     $app_strings = return_application_language($language);
     $admin = BeanFactory::getBean('Administration');
     $config = $admin->getConfigForModule('Forecasts', 'base');
     $timeperiodInterval = $config['timeperiod_interval'];
     $timeperiodLeafInterval = $config['timeperiod_leaf_interval'];
     $parentTimePeriod = TimePeriod::getLatest($timeperiodInterval);
     $latestTimePeriod = TimePeriod::getLatest($timeperiodLeafInterval);
     $currentTimePeriod = TimePeriod::getCurrentTimePeriod($timeperiodLeafInterval);
     if (empty($latestTimePeriod)) {
         $GLOBALS['log']->error(string_format($app_strings['ERR_TIMEPERIOD_TYPE_DOES_NOT_EXIST'], array($timeperiodLeafInterval)) . '[latest]');
         return false;
     } else {
         if (empty($currentTimePeriod)) {
             $GLOBALS['log']->error(string_format($app_strings['ERR_TIMEPERIOD_TYPE_DOES_NOT_EXIST'], array($timeperiodLeafInterval)) . ' [current]');
             return false;
         } else {
             if (empty($parentTimePeriod)) {
                 $GLOBALS['log']->error(string_format($app_strings['ERR_TIMEPERIOD_TYPE_DOES_NOT_EXIST'], array($timeperiodLeafInterval)) . ' [parent]');
                 return false;
             }
         }
     }
     $timedate = TimeDate::getInstance();
     //We run the rebuild command if the latest TimePeriod is less than the specified configuration interval
     //from the current TimePeriod
     $correctStartDate = $timedate->fromDbDate($currentTimePeriod->start_date);
     $latestStartDate = $timedate->fromDbDate($latestTimePeriod->start_date);
     $shownForward = $config['timeperiod_shown_forward'];
     //Move the current start date forward by the leaf period amounts
     for ($x = 0; $x < $shownForward; $x++) {
         $correctStartDate->modify($parentTimePeriod->next_date_modifier);
     }
     $leafCycle = $latestTimePeriod->leaf_cycle;
     //If the current start data that was modified according to the shown forward period is past the latest
     //leaf period we need to build more timeperiods
     while ($correctStartDate > $latestStartDate) {
         //We need to keep creating leaf periods until we are in sync.
         //If the leaf period we need to create is the start of the leaf cycle
         //then we should also create the parent TimePeriod record.
         $startDate = $latestStartDate->modify($latestTimePeriod->next_date_modifier);
         $leafCycle = $leafCycle == $parentTimePeriod->leaf_periods ? 1 : $leafCycle + 1;
         if ($leafCycle == 1) {
             $parentTimePeriod = TimePeriod::getByType($timeperiodInterval);
             $parentTimePeriod->setStartDate($startDate->asDbDate());
             $parentTimePeriod->name = $parentTimePeriod->getTimePeriodName($leafCycle);
             $parentTimePeriod->save();
         }
         $leafTimePeriod = TimePeriod::getByType($timeperiodLeafInterval);
         $leafTimePeriod->setStartDate($startDate->asDbDate());
         $leafTimePeriod->name = $leafTimePeriod->getTimePeriodName($leafCycle, $parentTimePeriod);
         $leafTimePeriod->leaf_cycle = $leafCycle;
         $leafTimePeriod->parent_id = $parentTimePeriod->id;
         $leafTimePeriod->save();
     }
     $this->job->succeedJob();
     return true;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:66,代码来源:SugarJobCreateNextTimePeriod.php

示例12: getAgenda

 public function getAgenda($api, $args)
 {
     // Fetch the next 14 days worth of meetings (limited to 20)
     $end_time = new SugarDateTime("+14 days");
     $start_time = new SugarDateTime("-1 hour");
     $meeting = BeanFactory::newBean('Meetings');
     $meetingList = $meeting->get_list('date_start', "date_start > " . $GLOBALS['db']->convert($GLOBALS['db']->quoted($start_time->asDb()), 'datetime') . " AND date_start < " . $GLOBALS['db']->convert($GLOBALS['db']->quoted($end_time->asDb()), 'datetime'));
     // Setup the breaks for the various time periods
     $datetime = new SugarDateTime();
     $today_stamp = $datetime->get_day_end()->getTimestamp();
     $tomorrow_stamp = $datetime->setDate($datetime->year, $datetime->month, $datetime->day + 1)->get_day_end()->getTimestamp();
     $timeDate = TimeDate::getInstance();
     $returnedMeetings = array('today' => array(), 'tomorrow' => array(), 'upcoming' => array());
     foreach ($meetingList['list'] as $meetingBean) {
         $meetingStamp = $timeDate->fromUser($meetingBean->date_start)->getTimestamp();
         $meetingData = $this->formatBean($api, $args, $meetingBean);
         if ($meetingStamp < $today_stamp) {
             $returnedMeetings['today'][] = $meetingData;
         } else {
             if ($meetingStamp < $tomorrow_stamp) {
                 $returnedMeetings['tomorrow'][] = $meetingData;
             } else {
                 $returnedMeetings['upcoming'][] = $meetingData;
             }
         }
     }
     return $returnedMeetings;
 }
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:28,代码来源:MeetingsApi.php

示例13: build

 /**
  * {@inheritDoc}
  */
 protected function build($builder)
 {
     $durations = \Service::getParameter('bzion.league.duration');
     foreach ($durations as $duration => &$value) {
         $durations[$duration] = $duration;
     }
     return $builder->add('first_team', new MatchTeamType())->add('second_team', new MatchTeamType())->add('duration', 'choice', array('choices' => $durations, 'constraints' => new NotBlank(), 'expanded' => true))->add('server_address', 'text', array('required' => false, 'attr' => array('placeholder' => 'brad.guleague.org:5100')))->add('time', new DatetimeWithTimezoneType(), array('constraints' => array(new NotBlank(), new LessThan(array('value' => \TimeDate::now()->addMinutes(10), 'message' => 'The timestamp of the match must not be in the future'))), 'data' => \TimeDate::now(\Controller::getMe()->getTimezone())))->add('enter', 'submit');
 }
开发者ID:kleitz,项目名称:bzion,代码行数:11,代码来源:MatchFormCreator.php

示例14: build

 /**
  * {@inheritdoc}
  */
 protected function build($builder)
 {
     $durations = \Service::getParameter('bzion.league.duration');
     foreach ($durations as $duration => &$value) {
         $durations[$duration] = $duration;
     }
     return $builder->add('first_team', new MatchTeamType(), array('disableTeam' => $this->isEdit() && $this->editing->isOfficial()))->add('second_team', new MatchTeamType(), array('disableTeam' => $this->isEdit() && $this->editing->isOfficial()))->add('duration', 'choice', array('choices' => $durations, 'constraints' => new NotBlank(), 'expanded' => true))->add('server_address', 'text', array('required' => false, 'attr' => array('placeholder' => 'brad.guleague.org:5100')))->add('time', new DatetimeWithTimezoneType(), array('constraints' => array(new NotBlank(), new LessThan(array('value' => \TimeDate::now()->addMinutes(10), 'message' => 'The timestamp of the match must not be in the future'))), 'data' => $this->isEdit() ? $this->editing->getTimestamp()->setTimezone(\Controller::getMe()->getTimezone()) : \TimeDate::now(\Controller::getMe()->getTimezone()), 'with_seconds' => $this->isEdit()))->add('map', new ModelType('Map'), array('required' => false))->add('type', 'choice', array('choices' => array(\Match::OFFICIAL => 'Official', \Match::FUN => 'Fun match', \Match::SPECIAL => 'Special event match'), 'disabled' => $this->editing && $this->editing->isOfficial(), 'label' => 'Match Type'))->add('enter', 'submit');
 }
开发者ID:allejo,项目名称:bzion,代码行数:11,代码来源:MatchFormCreator.php

示例15: testparseDateRange

 /**
  * @dataProvider dateRanges
  */
 public function testparseDateRange($range, $start, $end)
 {
     $this->time_date->setNow(SugarDateTime::createFromFormat(TimeDate::DB_DATETIME_FORMAT, "2011-08-30 12:01:02", new DateTimeZone($this->time_date->userTimezone())));
     $this->time_date->allow_cache = true;
     $daterage = $this->time_date->parseDateRange($range);
     $this->assertEquals($start, $daterage[0]->format(TimeDate::DB_DATETIME_FORMAT), 'Start date is wrong');
     $this->assertEquals($end, $daterage[1]->format(TimeDate::DB_DATETIME_FORMAT), 'End date is wrong');
 }
开发者ID:netconstructor,项目名称:sugarcrm_dev,代码行数:11,代码来源:TimeDateTest.php


注:本文中的TimeDate类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。