本文整理汇总了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;
}
示例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;
}
示例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
}
示例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";
}
}
示例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)));
}
示例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();
}
示例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
}
示例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>';
}
示例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;
}
示例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;
}
示例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
}
示例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);
}
示例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);
}
示例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;
}
示例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";
}
}