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


PHP DateTimeValueLib::now方法代码示例

本文整理汇总了PHP中DateTimeValueLib::now方法的典型用法代码示例。如果您正苦于以下问题:PHP DateTimeValueLib::now方法的具体用法?PHP DateTimeValueLib::now怎么用?PHP DateTimeValueLib::now使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DateTimeValueLib的用法示例。


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

示例1: purge_trash

 function purge_trash()
 {
     Env::useHelper("permissions");
     $days = config_option("days_on_trash", 0);
     $count = 0;
     if ($days > 0) {
         $date = DateTimeValueLib::now()->add("d", -$days);
         $objects = Objects::findAll(array("conditions" => array("`trashed_by_id` > 0 AND `trashed_on` < ?", $date), "limit" => 100));
         foreach ($objects as $object) {
             $concrete_object = Objects::findObject($object->getId());
             if (!$concrete_object instanceof ContentDataObject) {
                 continue;
             }
             if ($concrete_object instanceof MailContent && $concrete_object->getIsDeleted() > 0) {
                 continue;
             }
             try {
                 DB::beginWork();
                 if ($concrete_object instanceof MailContent) {
                     $concrete_object->delete(false);
                 } else {
                     $concrete_object->delete();
                 }
                 ApplicationLogs::createLog($concrete_object, ApplicationLogs::ACTION_DELETE);
                 DB::commit();
                 $count++;
             } catch (Exception $e) {
                 DB::rollback();
                 Logger::log("Error delting object in purge_trash: " . $e->getMessage(), Logger::ERROR);
             }
         }
     }
     return $count;
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:34,代码来源:Trash.class.php

示例2: rebuild

 public function rebuild($start_date = null, $end_date = null)
 {
     if (!$start_date) {
         $start_date = config_option('last_sharing_table_rebuild');
     }
     if ($start_date instanceof DateTimeValue) {
         $start_date = $start_date->toMySQL();
     }
     if ($end_date instanceof DateTimeValue) {
         $end_date = $end_date->toMySQL();
     }
     if ($end_date) {
         $end_cond = "AND updated_on <= '{$end_date}'";
     }
     try {
         $object_ids = Objects::instance()->findAll(array('id' => true, "conditions" => "updated_on >= '{$start_date}' {$end_cond}"));
         $obj_count = 0;
         DB::beginWork();
         foreach ($object_ids as $id) {
             $obj = Objects::findObject($id);
             if ($obj instanceof ContentDataObject) {
                 $obj->addToSharingTable();
                 $obj_count++;
             }
         }
         set_config_option('last_sharing_table_rebuild', DateTimeValueLib::now()->toMySQL());
         DB::commit();
     } catch (Exception $e) {
         DB::rollback();
         Logger::log("Failed to rebuild sharing table: " . $e->getMessage() . "\nTrace: " . $e->getTraceAsString());
     }
     return $obj_count;
 }
开发者ID:abhinay100,项目名称:fengoffice_app,代码行数:33,代码来源:SharingTables.class.php

示例3: check

 /**
  * Check if there is a new version of application available
  *
  * @param boolean $force When forced check will always construct the versions feed object
  *   try to fech the data and check for a new version. Version feed object is also returned
  * @return VersionFeed In case of error this function will return false
  */
 static function check($force = true)
 {
     $allow_url_fopen = strtolower(ini_get('allow_url_fopen'));
     if (function_exists('simplexml_load_file') && ($allow_url_fopen == '1' || $allow_url_fopen == 'on')) {
         // Execute once a day, if not forced check if we need to execute it now
         if (!$force) {
             if (config_option('upgrade_last_check_new_version', false)) {
                 return true;
                 // already have it checked and already have a new version
             }
             // if
             $last_check = config_option('upgrade_last_check_datetime');
             if ($last_check instanceof DateTimeValue && $last_check->getTimestamp() + 86400 > DateTimeValueLib::now()->getTimestamp()) {
                 return true;
                 // checked in the last day
             }
             // if
         }
         // if
         try {
             $versions_feed = new VersionsFeed();
             set_config_option('upgrade_last_check_datetime', DateTimeValueLib::now());
             set_config_option('upgrade_last_check_new_version', $versions_feed->hasNewVersions(product_version()));
             return $force ? $versions_feed : true;
         } catch (Exception $e) {
             return false;
         }
         // try
     } else {
         set_config_option('upgrade_check_enabled', false);
         return false;
     }
     // if
 }
开发者ID:469306621,项目名称:Languages,代码行数:41,代码来源:VersionChecker.class.php

示例4: cvs_total_task_times_table

	function cvs_total_task_times_table($objects, $pad_str, $options, $group_name, &$sub_total = 0) {
		
		echo lang('date') . ';';
		echo lang('title') . ';';
		echo lang('description') . ';';
		echo lang('person') . ';';
		echo lang('time') .'('.lang('hours').')'. ';';
		echo "\n";
		
		$sub_total = 0;
		
		foreach ($objects as $ts) {
			echo $pad_str . format_date($ts->getStartTime()) . ';';
			
			$name = ($ts->getRelObjectId() == 0 ? $ts->getObjectName() : $ts->getRelObject()->getObjectName());
			$name = str_replace("\r", " ", str_replace("\n", " ", str_replace("\r\n", " ", $name)));
			echo $name . ';';
			
			$desc = $ts->getDescription();
			$desc = str_replace("\r", " ", str_replace("\n", " ", str_replace("\r\n", " ", $desc)));
			$desc = '"'.$desc.'"';
			echo $desc .';';
			
			echo ($ts->getUser() instanceof Contact ? $ts->getUser()->getObjectName() : '') .';';
			$lastStop = $ts->getEndTime() != null ? $ts->getEndTime() : ($ts->isPaused() ? $ts->getPausedOn() : DateTimeValueLib::now());
			$mystring = DateTimeValue::FormatTimeDiff($ts->getStartTime(), $lastStop, "m", 60, $ts->getSubtract());
			$resultado = ereg_replace("[^0-9]", "", $mystring);
			$resultado = round(($resultado/60),5);
			echo $resultado;
			$sub_total += $resultado;
			echo "\n";
		}
	}
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:33,代码来源:total_task_times_csv.php

示例5: getDueReminders

 function getDueReminders($type = null)
 {
     if (isset($type)) {
         $extra = ' AND `type` = ' . DB::escape($type);
     } else {
         $extra = "";
     }
     return ObjectReminders::findAll(array('conditions' => array("`date` > '0000-00-00 00:00:00' AND `date` < ?" . $extra, DateTimeValueLib::now()), 'limit' => config_option('cron reminder limit', 100)));
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:9,代码来源:ObjectReminders.class.php

示例6: isYesterday

 /**
  * Returnst true if this application log was made yesterday
  *
  * @param void
  * @return boolean
  */
 function isYesterday()
 {
     $created_on = $this->getCreatedOn();
     if (!$created_on instanceof DateTimeValue) {
         return false;
     }
     $day_after = $created_on->advance(24 * 60 * 60, false);
     $now = DateTimeValueLib::now();
     return $now->getDay() == $day_after->getDay() && $now->getMonth() == $day_after->getMonth() && $now->getYear() == $day_after->getYear();
 }
开发者ID:rorteg,项目名称:fengoffice,代码行数:16,代码来源:ApplicationLog.class.php

示例7: getWhoIsOnline

 /**
  * Return all users that was active in past $active_in minutes (defautl is 15 minutes)
  *
  * @access public
  * @param integer $active_in
  * @return array
  */
 static function getWhoIsOnline($active_in = 15)
 {
     if ((int) $active_in < 1) {
         $active_in = 15;
     }
     $datetime = DateTimeValueLib::now();
     $datetime->advance(-1 * $active_in * 60);
     return Users::findAll(array('conditions' => array('`last_activity` > ?', $datetime)));
     // findAll
 }
开发者ID:bklein01,项目名称:Project-Pier,代码行数:17,代码来源:Users.class.php

示例8: total_task_times_print_table

function total_task_times_print_table($objects, $left, $options, $group_name, &$sub_total = 0, &$sub_total_billing = 0, &$sub_total_estimated = 0)
{
    echo '<div style="padding-left:' . $left . 'px;">';
    echo '<table class="reporting-table"><tr class="reporting-table-heading">';
    echo '<th>' . lang('date') . '</th>';
    echo '<th>' . lang('title') . '</th>';
    echo '<th>' . lang('description') . '</th>';
    echo '<th>' . lang('person') . '</th>';
    if (array_var($options, 'show_billing') == 'checked') {
        echo '<th class="right">' . lang('billing') . '</th>';
    }
    echo '<th class="right">' . lang('time') . '</th>';
    if ((array_var($options, 'timeslot_type') == 0 || array_var($options, 'timeslot_type') == 2) && array_var($options, 'show_estimated_time')) {
        echo '<th class="right">' . lang('estimated') . '</th>';
    }
    echo '</tr>';
    $sub_total = 0;
    $tasks = array();
    $alt_cls = "";
    foreach ($objects as $ts) {
        /* @var $ts Timeslot */
        echo "<tr {$alt_cls}>";
        echo "<td class='date'>" . format_date($ts->getStartTime()) . "</td>";
        echo "<td class='name'>" . ($ts->getRelObjectId() == 0 ? clean($ts->getObjectName()) : clean($ts->getRelObject()->getObjectName())) . "</td>";
        echo "<td class='name'>" . nl2br(clean($ts->getDescription())) . "</td>";
        echo "<td class='person'>" . clean($ts->getUser() instanceof Contact ? $ts->getUser()->getObjectName() : '') . "</td>";
        if (array_var($options, 'show_billing') == 'checked') {
            if ($ts->getIsFixedBilling()) {
                echo "<td class='nobr right'>" . config_option('currency_code', '$') . " " . number_format($ts->getFixedBilling(), 2) . "</td>";
                $sub_total_billing += $ts->getFixedBilling();
            } else {
                $min = $ts->getMinutes();
                echo "<td class='nobr right'>" . config_option('currency_code', '$') . " " . number_format($ts->getHourlyBilling() / 60 * $min, 2) . "</td>";
                $sub_total_billing += $ts->getHourlyBilling() / 60 * $min;
            }
        }
        $lastStop = $ts->getEndTime() != null ? $ts->getEndTime() : ($ts->isPaused() ? $ts->getPausedOn() : DateTimeValueLib::now());
        echo "<td class='time nobr right'>" . DateTimeValue::FormatTimeDiff($ts->getStartTime(), $lastStop, "hm", 60, $ts->getSubtract()) . "</td>";
        if ((array_var($options, 'timeslot_type') == 0 || array_var($options, 'timeslot_type') == 2) && $ts->getRelObject() instanceof ProjectTask && array_var($options, 'show_estimated_time')) {
            echo "<td class='time nobr right'>" . DateTimeValue::FormatTimeDiff(new DateTimeValue(0), new DateTimeValue($ts->getRelObject()->getTimeEstimate() * 60), 'hm', 60) . "</td>";
            $task = $ts->getRelObject();
            //check if I have the estimated time of this task
            if (!in_array($task->getId(), $tasks)) {
                $sub_total_estimated += $task->getTimeEstimate();
            }
            $tasks[] = $task->getId();
        } elseif ((array_var($options, 'timeslot_type') == 0 || array_var($options, 'timeslot_type') == 2) && array_var($options, 'show_estimated_time')) {
            echo "<td class='time nobr right'> 0 </td>";
        }
        echo "</tr>";
        $sub_total += $ts->getMinutes();
        $alt_cls = $alt_cls == "" ? 'class="alt-row"' : "";
    }
    echo '</table></div>';
}
开发者ID:abhinay100,项目名称:feng_app,代码行数:55,代码来源:total_task_times.php

示例9: getDueEvents

 function getDueEvents($date = null)
 {
     if (!$date instanceof DateTimeValue) {
         $date = DateTimeValueLib::now();
     }
     $events = self::findAll(array('conditions' => array('`date` <= ?', $date)));
     if (!is_array($events)) {
         return array();
     }
     return $events;
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:11,代码来源:CronEvents.class.php

示例10: getDueEvents

 function getDueEvents($date = null)
 {
     if (defined('REMOVE_AUTOLOADER_BEFORE_CRON') && REMOVE_AUTOLOADER_BEFORE_CRON) {
         @unlink(CACHE_DIR . "/autoloader.php");
     }
     if (!$date instanceof DateTimeValue) {
         $date = DateTimeValueLib::now();
     }
     $events = self::findAll(array('conditions' => array('`date` <= ?', $date)));
     if (!is_array($events)) {
         return array();
     }
     return $events;
 }
开发者ID:abhinay100,项目名称:feng_app,代码行数:14,代码来源:CronEvents.class.php

示例11: getOpenTicketsByUser

 /**
  * Return late tickets from active projects given user has access on.
  *
  * @param User $user
  * @return array or null
  */
 function getOpenTicketsByUser(User $user)
 {
     $due_date = DateTimeValueLib::now()->beginningOfDay();
     $projects = $user->getActiveProjects();
     if (!is_array($projects) || !count($projects)) {
         return null;
     }
     $project_ids = array();
     foreach ($projects as $project) {
         $project_ids[] = $project->getId();
     }
     // foreach
     return self::findAll(array('conditions' => array('`closed_on` = ? AND `project_id` IN (?)', EMPTY_DATETIME, $project_ids), 'order' => '`priority`'));
     // findAll
 }
开发者ID:469306621,项目名称:Languages,代码行数:21,代码来源:ProjectTickets.class.php

示例12: setValue

 /**
  * Set cookie value
  *
  * @param string $name Variable name
  * @param mixed $value
  * @param integer $expiration Number of seconds from current time when this cookie need to expire
  * @return null
  */
 static function setValue($name, $value, $expiration = null)
 {
     $expiration_time = DateTimeValueLib::now();
     if ((int) $expiration > 0) {
         $expiration_time->advance($expiration);
     } else {
         $expiration_time->advance(3600);
         // one hour
     }
     // if
     $path = defined('COOKIE_PATH') ? COOKIE_PATH : '/';
     $domain = defined('COOKIE_DOMAIN') ? COOKIE_DOMAIN : '';
     $secure = defined('COOKIE_SECURE') ? COOKIE_SECURE : false;
     setcookie($name, $value, $expiration_time->getTimestamp(), $path, $domain, $secure);
 }
开发者ID:swenson,项目名称:projectpier,代码行数:23,代码来源:Cookie.class.php

示例13: setValue

 /**
  * Set cookie value
  *
  * @param string $name Variable name
  * @param mixed $value
  * @param integer $expiration Number of seconds from current time when this cookie need to expire
  * @return null
  */
 static function setValue($name, $value, $expiration = null)
 {
     $expiration_time = DateTimeValueLib::now();
     if ((int) $expiration > 0) {
         $expiration_time->advance($expiration);
     } else {
         $expiration_time->advance(3600);
         // one hour
     }
     // if
     // if $expiration is null, set the cookie to expire when the session is over
     $expiration_timestamp = is_null($expiration) ? null : $expiration_time->getTimestamp();
     $path = defined('COOKIE_PATH') ? COOKIE_PATH : '/';
     $domain = defined('COOKIE_DOMAIN') ? COOKIE_DOMAIN : '';
     $secure = defined('COOKIE_SECURE') ? COOKIE_SECURE : false;
     setcookie($name, $value, $expiration_timestamp, $path, $domain, $secure);
 }
开发者ID:469306621,项目名称:Languages,代码行数:25,代码来源:Cookie.class.php

示例14: purge_trash

 function purge_trash()
 {
     Env::useHelper("permissions");
     $days = config_option("days_on_trash", 0);
     $count = 0;
     if ($days > 0) {
         $date = DateTimeValueLib::now()->add("d", -$days);
         $managers = array('Comments', 'Companies', 'Contacts', 'MailContents', 'ProjectCharts', 'ProjectEvents', 'ProjectFiles', 'ProjectFileRevisions', 'ProjectForms', 'ProjectMessages', 'ProjectMilestones', 'ProjectTasks', 'ProjectWebpages');
         foreach ($managers as $manager_class) {
             $manager = new $manager_class();
             $prevcount = -1;
             while ($prevcount != $count) {
                 $prevcount = $count;
                 if ($manager_class == 'MailContents') {
                     $objects = $manager->findAll(array("include_trashed" => true, "conditions" => array("`trashed_by_id` > 0 AND `trashed_on` < ? AND `is_deleted` = 0", $date), "limit" => 100));
                 } else {
                     $objects = $manager->findAll(array("include_trashed" => true, "conditions" => array("`trashed_by_id` > 0 AND `trashed_on` < ?", $date), "limit" => 100));
                 }
                 if (is_array($objects)) {
                     // delete one by one because each one knows what else to delete
                     foreach ($objects as $o) {
                         try {
                             DB::beginWork();
                             $ws = $o->getWorkspaces();
                             if ($o instanceof MailContent) {
                                 $o->delete(false);
                             } else {
                                 $o->delete();
                             }
                             ApplicationLogs::createLog($o, $ws, ApplicationLogs::ACTION_DELETE);
                             DB::commit();
                             $count++;
                         } catch (Exception $e) {
                             DB::rollback();
                             Logger::log("Error deleting object in purge_trash: " . $e->getMessage(), Logger::ERROR);
                         }
                     }
                 }
             }
         }
     }
     return $count;
 }
开发者ID:pnagaraju25,项目名称:fengoffice,代码行数:43,代码来源:Trash.class.php

示例15: cvs_total_task_times_table

function cvs_total_task_times_table($objects, $pad_str, $options, $group_name, &$sub_total = 0)
{
    echo lang('date') . ';';
    echo lang('title') . ';';
    echo lang('description') . ';';
    echo lang('person') . ';';
    echo lang('time') . ';';
    echo "\n";
    $sub_total = 0;
    foreach ($objects as $ts) {
        echo $pad_str . format_date($ts->getStartTime()) . ';';
        echo ($ts->getRelObjectId() == 0 ? clean($ts->getObjectName()) : clean($ts->getRelObject()->getObjectName())) . ';';
        echo clean($ts->getDescription()) . ';';
        echo clean($ts->getUser()->getObjectName()) . ';';
        $lastStop = $ts->getEndTime() != null ? $ts->getEndTime() : ($ts->isPaused() ? $ts->getPausedOn() : DateTimeValueLib::now());
        echo DateTimeValue::FormatTimeDiff($ts->getStartTime(), $lastStop, "hm", 60, $ts->getSubtract()) . ';';
        $sub_total += $ts->getMinutes();
        echo "\n";
    }
}
开发者ID:rorteg,项目名称:fengoffice,代码行数:20,代码来源:total_task_times_csv.php


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