/** * Return formated datetime * * @access public * @param DateTimeValue $value If value is not instance of DateTime object new DateTime * object will be created with $value as its constructor param * @param string $format If $format is NULL default datetime format will be used * @param float $timezone Timezone, if NULL it will be autodetected (by currently logged user if we have it) * @return string */ function format_datetime($value = null, $format = null, $timezone = null) { if(is_null($timezone) && function_exists('logged_user') && (logged_user() instanceof Contact)) { $timezone = logged_user()->getTimezone(); } // if $datetime = $value instanceof DateTimeValue ? $value : new DateTimeValue($value); if ($format){ $l = new Localization(); $l->setDateTimeFormat($format); }else $l = Localization::instance(); return $l->formatDateTime($datetime, $timezone); } // format_datetime
private function build_original_mail_info($original_mail, $type = 'plain') { $loc = new Localization(); $loc->setDateTimeFormat("D, d M Y H:i:s O"); if ($type == 'plain') { $cc_cell = $original_mail->getCc() == '' ? '' : "\n".lang('mail CC').": ".$original_mail->getCc(); $str = "\n\n----- ".lang('original message')."-----\n".lang('mail from').": ".$original_mail->getFrom()."\n".lang('mail to').": ".$original_mail->getTo()."$cc_cell\n".lang('mail sent').": ".$loc->formatDateTime($original_mail->getSentDate(), logged_user()->getTimezone())."\n".lang('mail subject').": ".$original_mail->getSubject()."\n\n"; } else { $cc_cell = $original_mail->getCc() == '' ? '' : "<tr><td>".lang('mail CC').": ".$original_mail->getCc()."</td></tr>"; $str = "<br><br><table><tr><td>----- ".lang('original message')." -----</td></tr><tr><td>".lang('mail from').": ".$original_mail->getFrom()."</td></tr><tr><td>".lang('mail to').": ".$original_mail->getTo()."</td></tr>$cc_cell<tr><td>".lang('mail sent').": ".$loc->formatDateTime($original_mail->getSentDate(), logged_user()->getTimezone())."</td></tr><tr><td>".lang('mail subject').": ".$original_mail->getSubject()."</td></tr></table><br>"; } return $str; }
/** * Return formated datetime * * @access public * @param DateTimeValue $value If value is not instance of DateTime object new DateTime * object will be created with $value as its constructor param * @param string $format If $format is NULL default datetime format will be used * @param float $timezone Timezone, if NULL it will be autodetected (by currently logged user if we have it) * @return string */ function format_datetime($value = null, $format = null, $timezone = null) { if (is_null($timezone) && function_exists('logged_user') && logged_user() instanceof Contact) { $timezone = logged_user()->getTimezone(); } // if $datetime = $value instanceof DateTimeValue ? $value : new DateTimeValue($value); if ($format) { $l = new Localization(); $l->setDateTimeFormat($format); } else { $l = Localization::instance(); $formatTime = user_config_option('time_format_use_24') ? 'G:i' : 'g:i A'; $format = user_config_option('date_format') . ' ' . $formatTime; $l->setDateTimeFormat($format); } return $l->formatDateTime($datetime, $timezone); }