本文整理汇总了PHP中TimeDate::to_display_date_time方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeDate::to_display_date_time方法的具体用法?PHP TimeDate::to_display_date_time怎么用?PHP TimeDate::to_display_date_time使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeDate
的用法示例。
在下文中一共展示了TimeDate::to_display_date_time方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testToDisplayDateTimeFormats
/**
* test conversion from DB date+time to local date+time with TZ handling
* @dataProvider dateTestSet
*/
public function testToDisplayDateTimeFormats($db, $df, $tf, $tz, $display, $dbdate)
{
$this->_setPrefs($df, $tf, $tz);
$result = $this->time_date->to_display_date_time($db, true, true, $GLOBALS['current_user']);
if (empty($tf)) {
$result = $this->_dateOnly($result);
}
$this->assertEquals($display, $result, "Broken conversion for '{$df}' with date '{$db}' and TZ {$tz}");
}
示例2: getMarkerData
/**
* Define marker data for marker display view
* @param $module_type bean name
* @param $display bean fields array
* $param $mod_strings_display mod_strings from display module
* TODO: Use a custom defined field for the $marker['group']
*/
function getMarkerData($module_type, $display, $center_marker = false, $mod_strings_display = array())
{
// echo "<pre>";
// print_r($display);
// print_r($mod_strings_display);
// echo "</pre>";
// Define Marker
$marker = array();
// Set only partial display data for efficiency
$marker['name'] = $display['name'];
// Or, Set all display data for flexibility
//$marker = $display;
if (empty($marker['name'])) {
$marker['name'] = 'N/A';
}
$marker['id'] = $display['id'];
$marker['module'] = $module_type;
$marker['address'] = $display['jjwg_maps_address_c'];
$marker['lat'] = $display['jjwg_maps_lat_c'];
if (!$this->is_valid_lat($marker['lat'])) {
$marker['lat'] = '0';
}
$marker['lng'] = $display['jjwg_maps_lng_c'];
if (!$this->is_valid_lng($marker['lng'])) {
$marker['lng'] = '0';
}
// Define a phone field: phone_office, phone_work, phone_mobile
if (!empty($display['phone_office'])) {
$marker['phone'] = $display['phone_office'];
} elseif (!empty($display['phone_work'])) {
$marker['phone'] = $display['phone_work'];
} elseif (!empty($display['phone_mobile'])) {
$marker['phone'] = $display['phone_mobile'];
} else {
$marker['phone'] = '';
}
if ($marker['lat'] != '0' && $marker['lng'] != '0') {
// Check to see if marker point already exists and apply offset if needed
// This often occurs when an address is only defined by city, state, zip.
$i = 0;
while (isset($this->map_marker_data_points[(string) $marker['lat']][(string) $marker['lng']]) && $i < $this->settings['map_markers_limit']) {
$marker['lat'] = (double) $marker['lat'] + (double) $this->settings['map_duplicate_marker_adjustment'];
$marker['lng'] = (double) $marker['lng'] + (double) $this->settings['map_duplicate_marker_adjustment'];
$i++;
}
// Set Marker Point as Used (true)
$this->map_marker_data_points[(string) $marker['lat']][(string) $marker['lng']] = true;
if (isset($display['account_name'])) {
$marker['account_name'] = $display['account_name'];
}
if (isset($display['account_id'])) {
$marker['account_id'] = $display['account_id'];
}
$marker['assigned_user_name'] = isset($display['assigned_user_name']) ? $display['assigned_user_name'] : '';
$marker['image'] = isset($display['marker_image']) ? $display['marker_image'] : '';
// Define Marker Group
if (!$center_marker) {
// Group Field for the Display Module
$group_field_name = $this->settings['map_markers_grouping_field'][$module_type];
$group_field_value = $display[$group_field_name];
// Check for DOM field types (enum type)
if (isset($this->display_object->field_name_map[$group_field_name]['type']) && $this->display_object->field_name_map[$group_field_name]['type'] == 'enum') {
$group_field_dom = $this->display_object->field_name_map[$group_field_name]['options'];
$marker['group'] = $GLOBALS['app_list_strings'][$group_field_dom][$group_field_value];
} elseif (!empty($display[$group_field_name])) {
$marker['group'] = $display[$group_field_name];
} else {
$marker['group'] = $GLOBALS['mod_strings']['LBL_MAP_NULL_GROUP_NAME'];
// null group
}
if (!in_array($marker['group'], $this->bean->map_markers_groups)) {
$this->bean->map_markers_groups[] = $marker['group'];
}
}
/**
* Define Dates for Meetings
* TimeDate.php to_display_date_time()
* Note, date time fields are converted to the User's date time settings
*/
if ($module_type == 'Meetings') {
require_once 'modules/Meetings/Meeting.php';
require_once 'include/TimeDate.php';
if (!isset($meetingTimeDate) || !is_object($meetingTimeDate)) {
$meetingTimeDate = new TimeDate();
}
$display['date_start'] = $meetingTimeDate->to_display_date_time($display['date_start'], true, true, $GLOBALS['current_user']);
$display['date_end'] = $meetingTimeDate->to_display_date_time($display['date_end'], true, true, $GLOBALS['current_user']);
}
$current_user_data = get_object_vars($GLOBALS['current_user']);
$this->sugarSmarty->assign('current_user', $current_user_data);
$this->sugarSmarty->assign('current_user_address', $this->bean->defineMapsFormattedAddress($current_user_data, 'address'));
$this->sugarSmarty->assign("mod_strings", $mod_strings_display);
// Define Maps Info Window HTML by Sugar Smarty Template
//.........这里部分代码省略.........
示例3: TimeDate
/**
* This function retrieves a record of the appropriate type from the DB.
* It fills in all of the fields from the DB into the object it was called on.
*
* @param $id - If ID is specified, it overrides the current value of $this->id. If not specified the current value of $this->id will be used.
* @return this - The object that it was called apon or null if exactly 1 record was not found.
*
*/
function check_date_relationships_load()
{
global $disable_date_format;
if (!empty($disable_date_format)) {
return;
}
global $timedate;
if (empty($timedate)) {
$timedate = new TimeDate();
}
if (empty($this->field_defs)) {
return;
}
foreach ($this->field_defs as $fieldDef) {
$field = $fieldDef['name'];
if (!isset($this->processed_dates_times[$field])) {
$this->processed_dates_times[$field] = '1';
if ($field == 'date_modified' || $field == 'date_entered') {
if (!empty($this->{$field})) {
$this->{$field} = $timedate->to_display_date_time($this->{$field});
}
} elseif (!empty($this->{$field}) && isset($this->field_name_map[$field]['type'])) {
$type = $this->field_name_map[$field]['type'];
if ($type == 'relate' && isset($this->field_name_map[$field]['custom_module'])) {
$type = $this->field_name_map[$field]['type'];
}
if ($type == 'date') {
$this->{$field} = from_db_convert($this->{$field}, 'date');
if ($this->{$field} == '0000-00-00') {
$this->{$field} = '';
} elseif (!empty($this->field_name_map[$field]['rel_field'])) {
$rel_field = $this->field_name_map[$field]['rel_field'];
if (!empty($this->{$rel_field})) {
$this->{$rel_field} = from_db_convert($this->{$rel_field}, 'time');
$mergetime = $timedate->merge_date_time($this->{$field}, $this->{$rel_field});
$this->{$field} = $timedate->to_display_date($mergetime);
$this->{$rel_field} = $timedate->to_display_time($mergetime);
}
} else {
$this->{$field} = $timedate->to_display_date($this->{$field}, false);
}
} elseif ($type == 'datetime') {
if ($this->{$field} == '0000-00-00 00:00:00') {
$this->{$field} = '';
} else {
$this->{$field} = $timedate->to_display_date_time($this->{$field});
}
} elseif ($type == 'time') {
if ($this->{$field} == '00:00:00') {
$this->{$field} = '';
} else {
//$this->$field = from_db_convert($this->$field, 'time');
if (empty($this->field_name_map[$field]['rel_field'])) {
$this->{$field} = $timedate->to_display_time($this->{$field}, true, false);
}
}
} elseif ($type == 'encrypt') {
$this->{$field} = $this->decrypt_after_retrieve($this->{$field});
}
}
}
}
}
示例4: handleDateFormat
/**
* handles some date/time foramtting
* @param string time Time (usually "now")
* @param object user User, usually admin (id = '1')
* @return string formatted time.
*/
function handleDateFormat($time, $user = null)
{
global $timedate;
if (!isset($timedate) || empty($timedate)) {
$timedate = new TimeDate();
}
// get proper user
$user = empty($user) ? $this->user : $user;
$dbTime = gmdate('Y-m-d H:i:s', strtotime($time));
$ret = $timedate->to_display_date_time($dbTime, true, true, $user);
return $ret;
}
示例5: GoogleCalls
function GoogleCalls(&$bean, $event, $arguments)
{
echo "<br>aa " . $bean->id;
echo "<br>aa " . $bean->name;
echo "<br>sess delete " . $_SESSION["mass_upd_assigned"];
echo "<br>sess delete" . $_REQUEST["massupdate"];
echo "<br>";
$okev = true;
$_SESSION["mass_upd_assigned"] = false;
if (isset($_REQUEST["massupdate"])) {
if ($_REQUEST["massupdate"] == true) {
$okev = false;
if ($_REQUEST['assigned_user_id'] != "" or $_REQUEST['date_start'] != "") {
$okev = true;
}
if ($_REQUEST['assigned_user_id'] != "") {
$_SESSION["mass_upd_assigned"] = true;
}
}
}
if ($okev == true) {
if ($_SESSION["called_from_sync"] == false or $_SESSION["called_from_sync"] == "") {
### skip if called from sync.php logic hook
echo "<br>delete from sugar logic hook ";
global $timedate;
$offset_val = ".000+02:00";
$td = new TimeDate();
echo "<br>old bean id " . $bean->id;
echo "<br>old bean name " . $bean->name;
echo "<br>tablename ";
$tablename = $bean->table_name;
$a = $response['list'][$tn1];
$s = array();
$s["title"] = $bean->name;
if ($tablename == 'meetings') {
$s["title"] = "Meeting: " . $s["title"];
}
if ($tablename == 'calls') {
$s["title"] = "Call: " . $s["title"];
}
if ($tablename == 'tasks') {
$s["title"] = "Task: " . $s["title"];
}
echo "<br>bean date start " . $bean->date_start;
$s["content"] = $bean->description;
$s["where"] = $bean->location;
$s["startDay"] = $bean->date_start;
$s["startTime"] = $bean->time_start;
$s["endDay"] = $bean->date_end;
$s["reminder_time"] = $bean->reminder_time / 60;
if ($s["reminder_time"] == '' or $s["reminder_time"] == 0) {
$s["reminder_time"] = 10;
}
if ($bean->date_start == '' and $bean->date_due != "") {
$s["startDay"] = $bean->date_due;
#### for tasks if no start date
} else {
$s["startDay"] = $bean->date_start;
}
# print_r($s);
global $current_user;
$pd = $s["startDay"];
####260608
#$pd= $td->handle_offset($td->get_date_time_format(true, $current_user), $td->get_date_time_format(true, $current_user), false,$current_user);
$date_start_in_db_fmt = $td->swap_formats($s["startDay"], $td->get_date_time_format(true, $current_user), $td->get_db_date_time_format());
$date_end_in_db_fmt1 = $td->swap_formats($bean->date_due, $td->get_date_time_format(true, $current_user), $td->get_db_date_time_format());
$date_start_array = split(" ", trim($date_start_in_db_fmt));
$date_time_start = DateTimeUtil::get_time_start($date_start_array[0], $date_start_array[1]);
$tt1 = $td->to_display_date_time($bean->date_start, true, true, false);
$user = $current_user;
$s["startTime"] = $td->handle_offset($date_start_in_db_fmt, "H:i:s", false, $current_user);
$date_end_in_db_fmt1 = $td->handle_offset($date_end_in_db_fmt1, "Y-m-d H:i:s", false, $current_user);
echo "<br>bean date start1 " . $s["startTime"];
##260806 $s["startTime"]=$date_start_array[1];
echo "<br>bean date start2 " . $s["startTime"];
$ch = explode(" ", $s["startDay"]);
if ($ch['1'] == "00:00" or $ch['1'] == "00.00") {
#### 120608 bogdan if task and 12:00 goes to next day $s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false,$current_user);
$s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false, $current_user);
$s["startDay1"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d H:i:s", false, $current_user);
} else {
$s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false, $current_user);
$s["startDay1"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d H:i:s", false, $current_user);
}
$plugin_format = "d/m/Y H:i";
if ($td->get_date_time_format(true, $current_user) != $plugin_format) {
##260608 $plugin_date_start=$td->swap_formats($pd, $td->get_date_time_format(true, $current_user), $plugin_format);
$plugin_date_due = $td->swap_formats($bean->date_due, $td->get_date_time_format(true, $current_user), $plugin_format);
} else {
##260608 $plugin_date_start=$pd;
$plugin_date_due = $bean->date_due;
}
$plugin_date_start = $td->swap_formats($s["startDay1"], "Y-m-d H:i:s", $plugin_format);
$plugin_date_due1 = $td->swap_formats($date_end_in_db_fmt1, "Y-m-d H:i:s", $plugin_format);
echo "<br>plg date start " . $plugin_date_start;
#################################################
$d1 = explode("/", $plugin_date_start);
global $current_user;
$d1[2] = explode(" ", $d1[2]);
$d1[2] = $d1[2][0];
//.........这里部分代码省略.........
示例6: GoogleCalls
function GoogleCalls(&$bean, $event, $arguments)
{
$okev = true;
$_SESSION["mass_upd_assigned"] = false;
if (isset($_REQUEST["massupdate"])) {
if ($_REQUEST["massupdate"] == true) {
$okev = false;
if ($_REQUEST['assigned_user_id'] != "" or $_REQUEST['date_start'] != "") {
$okev = true;
}
if ($_REQUEST['assigned_user_id'] != "") {
$_SESSION["mass_upd_assigned"] = true;
}
}
}
if ($okev == true) {
if ($_SESSION["called_from_sync"] == false or $_SESSION["called_from_sync"] == "") {
### skip if called from sync.php logic hook
global $timedate;
$offset_val = ".000+02:00";
$td = new TimeDate();
$tablename = $bean->table_name;
$a = $response['list'][$tn1];
$s = array();
# echo "<br>**********Event ******* id=$a[id] ***** name=$a[name]";
$s["title"] = $bean->name;
if ($tablename == 'meetings') {
$s["title"] = "Meeting: " . $s["title"];
}
if ($tablename == 'calls') {
$s["title"] = "Call: " . $s["title"];
}
if ($tablename == 'tasks') {
$s["title"] = "Task: " . $s["title"];
}
$s["content"] = $bean->description;
$s["where"] = $bean->location;
$s["startDay"] = $bean->date_start;
$s["startTime"] = $bean->time_start;
$s["endDay"] = $bean->date_end;
$s["reminder_time"] = $bean->reminder_time / 60;
if ($s["reminder_time"] == '' or $s["reminder_time"] == 0) {
$s["reminder_time"] = 10;
}
if ($bean->date_start == '' and $bean->date_due != "") {
$s["startDay"] = $bean->date_due;
#### for tasks if no start date
} else {
$s["startDay"] = $bean->date_start;
}
# print_r($s);
global $current_user;
$pd = $s["startDay"];
####260608
#$pd= $td->handle_offset($td->get_date_time_format(true, $current_user), $td->get_date_time_format(true, $current_user), false,$current_user);
$date_start_in_db_fmt = $td->swap_formats($s["startDay"], $td->get_date_time_format(true, $current_user), $td->get_db_date_time_format());
$date_end_in_db_fmt1 = $td->swap_formats($bean->date_due, $td->get_date_time_format(true, $current_user), $td->get_db_date_time_format());
$date_start_array = split(" ", trim($date_start_in_db_fmt));
$date_time_start = DateTimeUtil::get_time_start($date_start_array[0], $date_start_array[1]);
$tt1 = $td->to_display_date_time($bean->date_start, true, true, false);
$user = $current_user;
$s["startTime"] = $td->handle_offset($date_start_in_db_fmt, "H:i:s", false, $current_user);
$date_end_in_db_fmt1 = $td->handle_offset($date_end_in_db_fmt1, "Y-m-d H:i:s", false, $current_user);
###### problem with offset ... if record is at 23.15 gmt +2 .. date problem
$ch = explode(" ", $s["startDay"]);
if ($ch['1'] == "00:00" or $ch['1'] == "00.00") {
#### 120608 bogdan if task and 12:00 goes to next day $s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false,$current_user);
$s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false, $current_user);
$s["startDay1"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d H:i:s", false, $current_user);
} else {
$s["startDay"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d", false, $current_user);
$s["startDay1"] = $td->handle_offset($date_start_in_db_fmt, "Y-m-d H:i:s", false, $current_user);
}
$plugin_format = "d/m/Y H:i";
if ($td->get_date_time_format(true, $current_user) != $plugin_format) {
##260608 $plugin_date_start=$td->swap_formats($pd, $td->get_date_time_format(true, $current_user), $plugin_format);
$plugin_date_due = $td->swap_formats($bean->date_due, $td->get_date_time_format(true, $current_user), $plugin_format);
} else {
##260608 $plugin_date_start=$pd;
$plugin_date_due = $bean->date_due;
}
$plugin_date_start = $td->swap_formats($s["startDay1"], "Y-m-d H:i:s", $plugin_format);
$plugin_date_due1 = $td->swap_formats($date_end_in_db_fmt1, "Y-m-d H:i:s", $plugin_format);
#################################################
$d1 = explode("/", $plugin_date_start);
global $current_user;
$d1[2] = explode(" ", $d1[2]);
$d1[2] = $d1[2][0];
if ($bean->time_start != '' and 1 == 2) {
$t1 = explode(":", $bean->time_start);
} else {
$fort1 = explode(" ", $plugin_date_start);
$fort1 = $fort1[1];
$t1 = explode(":", $fort1);
}
$t1[1] = round($t1[1]);
$untill = mktime($t1[0] + $bean->duration_hours, $t1[1] + $bean->duration_minutes, $t1[2], $d1[1], $d1[0], $d1[2]);
if ($tablename == 'tasks') {
if ($plugin_date_due == "" or $bean->date_due == "") {
$forexp = $plugin_date_start;
//.........这里部分代码省略.........
示例7: handleDateFormat
/**
* handles some date/time foramtting
* @param string time Time (usually "now")
* @param object user User, usually admin (id = '1')
* @param boolean to_local, convert to user's time format
* @return string formatted time.
*/
function handleDateFormat($time, $user = null, $to_local = true)
{
global $timedate;
if (!isset($timedate) || empty($timedate)) {
$timedate = new TimeDate();
}
// get proper user
$user = empty($user) ? $this->user : $user;
$dbTime = $timedate->nowDb();
if ($to_local) {
$ret = $timedate->to_display_date_time($dbTime, true, true, $user);
return $ret;
}
return $dbTime;
}