本文整理汇总了PHP中TimeDate::getNow方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeDate::getNow方法的具体用法?PHP TimeDate::getNow怎么用?PHP TimeDate::getNow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeDate
的用法示例。
在下文中一共展示了TimeDate::getNow方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testUserDateFormat
public function testUserDateFormat()
{
$gmt_default_date_start = $this->time_date->get_gmt_db_datetime();
$date1 = $this->time_date->handle_offset($gmt_default_date_start, $GLOBALS['timedate']->get_date_time_format());
$date2 = $this->time_date->asUser($this->time_date->getNow());
$this->assertEquals($date1, $date2, "HandleOffset should be equaivalent to nowDb");
}
示例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;
}
示例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();
}
}
示例4: handleDateFormat
/**
* handleDateFormat
*
* This function handles returning a datetime value. It allows a user instance to be passed in, but will default to the
* user member variable instance if none is found.
*
* @param string $date String value of the date to calculate, defaults to 'now'
* @param object $user The User instance to use in calculating the time value, if empty, it will default to user member variable
* @param boolean $user_format Boolean indicating whether or not to convert to user's time format, defaults to false
*
* @return string Formatted datetime value
*/
function handleDateFormat($date = 'now', $user = null, $user_format = false)
{
global $timedate;
if (!isset($timedate) || empty($timedate)) {
$timedate = new TimeDate();
}
// get user for calculation
$user = empty($user) ? $this->user : $user;
if ($date == 'now') {
$dbTime = $timedate->asUser($timedate->getNow(), $user);
} else {
$dbTime = $timedate->asUser($timedate->fromString($date, $user), $user);
}
// if $user_format is set to true then just return as th user's time format, otherwise, return as database format
return $user_format ? $dbTime : $timedate->fromUser($dbTime, $user)->asDb();
}
示例5: Opportunity
if (empty($contact->last_name)) {
$contact->last_name = $contact_last_name;
}
if (empty($contact->mobile)) {
$contact->mobile = $contact_mobile;
}
if (empty($contact->assigned_user_id)) {
$contact->assigned_user_id = 1;
}
$contact->save();
} else {
$contact->first_name = $contact_first_name;
$contact->last_name = $contact_last_name;
$contact->email1 = $contact_email;
$contact->mobile = $contact_mobile;
$contact->assigned_user_id = 1;
$contact->save();
$contact->load_relationship('accounts');
$contact->accounts->add($account->id);
}
// Create the Opportunity
$opportunity = new Opportunity();
$opportunity->name = $opportunity_name;
$opportunity->amount = $opportunity_amount;
$opportunity->date_closed = $timeDate->getNow(true)->asDbDate();
$opportunity->sales_stage = "Closed Won";
$opportunity->account_id = $account->id;
$opportunity->assigned_user_id = 1;
$opportunity->save();
$opportunity->load_relationship('contacts');
$opportunity->contacts->add($contact->id);