本文整理汇总了PHP中TTDate::setTimeFormat方法的典型用法代码示例。如果您正苦于以下问题:PHP TTDate::setTimeFormat方法的具体用法?PHP TTDate::setTimeFormat怎么用?PHP TTDate::setTimeFormat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTDate
的用法示例。
在下文中一共展示了TTDate::setTimeFormat方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_parseEpoch
function test_parseEpoch()
{
Debug::text('Testing Date Parsing of EPOCH!', __FILE__, __LINE__, __METHOD__, 10);
TTDate::setDateFormat('m-d-y');
TTDate::setTimeZone('PST');
TTDate::setTimeFormat('g:i A');
$this->assertEquals(TTDate::parseDateTime(1162670400), (int) 1162670400);
TTDate::setDateFormat('Y-m-d');
TTDate::setTimeZone('PST');
TTDate::setTimeFormat('g:i A');
$this->assertEquals(TTDate::parseDateTime(1162670400), (int) 1162670400);
$this->assertEquals(TTDate::parseDateTime(600), (int) 600);
//Test small epochs that may conflict with 24hr time that just has the time and not a date.
$this->assertEquals(TTDate::parseDateTime(1800), (int) 1800);
//Test small epochs that may conflict with 24hr time that just has the time and not a date.
$this->assertEquals(TTDate::parseDateTime(-600), (int) -600);
//Test small epochs that may conflict with 24hr time that just has the time and not a date.
$this->assertEquals(TTDate::parseDateTime(-1800), (int) -1800);
//Test small epochs that may conflict with 24hr time that just has the time and not a date.
}
示例2: test_parseEpoch
function test_parseEpoch()
{
Debug::text('Testing Date Parsing of EPOCH!', __FILE__, __LINE__, __METHOD__, 10);
TTDate::setDateFormat('m-d-y');
TTDate::setTimeZone('PST');
TTDate::setTimeFormat('g:i A');
$this->assertEquals(TTDate::parseDateTime(1162670400), (int) 1162670400);
TTDate::setDateFormat('Y-m-d');
TTDate::setTimeZone('PST');
TTDate::setTimeFormat('g:i A');
$this->assertEquals(TTDate::parseDateTime(1162670400), (int) 1162670400);
}
示例3: parse_time_stamp
function parse_time_stamp($input, $default_value = NULL, $parse_hint = NULL)
{
//Use this to manually force a specific timezone.
//TTDate::setTimeZone('GMT');
if (strpos($parse_hint, '#') !== FALSE) {
$split_parse_hint = explode('#', $parse_hint);
}
if (isset($split_parse_hint[0]) and $split_parse_hint[0] != '') {
TTDate::setDateFormat($split_parse_hint[0]);
}
if (isset($split_parse_hint[1]) and $split_parse_hint[1] != '') {
TTDate::setTimeFormat($split_parse_hint[1]);
} else {
TTDate::setTimeFormat('g:i A');
}
return TTDate::parseDateTime($input);
}
示例4: _postParseRow
function _postParseRow($row_number, $raw_row)
{
$raw_row['user_id'] = $this->getUserIdByRowData($raw_row);
if ($raw_row['user_id'] == FALSE) {
unset($raw_row['user_id']);
}
//Combine date/time columns together and convert all time_stamp columns into epochs.
$column_map = $this->getColumnMap();
//Include columns that should always be there.
//Handle one punch per row.
if (isset($column_map['time_stamp'])) {
Debug::Text('Parsing time_stamp column...', __FILE__, __LINE__, __METHOD__, 10);
$date_time_format = $column_map['time_stamp']['parse_hint'] . '_' . $column_map['time_stamp']['parse_hint'];
} elseif (!isset($column_map['time_stamp']) and isset($column_map['date']) and isset($column_map['time'])) {
Debug::Text('Parsing date/time column...', __FILE__, __LINE__, __METHOD__, 10);
//$raw_row['time_stamp'] = $raw_row[$column_map['date']['map_column_name']].' '. $raw_row[$column_map['time']['map_column_name']];
$raw_row['time_stamp'] = $raw_row['date'] . ' ' . $raw_row['time'];
$date_time_format = $column_map['date']['parse_hint'] . '_' . $column_map['time']['parse_hint'];
unset($raw_row['date'], $raw_row['time']);
} else {
$date_time_format = 'd-M-y_g:i A T';
}
if (isset($raw_row['time_stamp'])) {
$split_date_time_format = explode('_', $date_time_format);
//Debug::Arr($split_date_time_format, 'Date/Time Format: '. $date_time_format, __FILE__, __LINE__, __METHOD__,10);
TTDate::setDateFormat($split_date_time_format[0]);
TTDate::setTimeFormat($split_date_time_format[1]);
$raw_row['time_stamp'] = TTDate::parseDateTime($raw_row['time_stamp']);
}
//Debug::Arr($column_map, 'Column Map', __FILE__, __LINE__, __METHOD__,10);
//Debug::Arr($raw_row, 'Raw Row', __FILE__, __LINE__, __METHOD__,10);
//Handle two punches per row.
if (isset($column_map['in_time_stamp']) and isset($column_map['out_time_stamp'])) {
Debug::Text('Parsing Two punches per row...', __FILE__, __LINE__, __METHOD__, 10);
$in_date_time_format = $column_map['in_time_stamp']['parse_hint'] . '_' . $column_map['in_time_stamp']['parse_hint'];
$out_date_time_format = $column_map['out_time_stamp']['parse_hint'] . '_' . $column_map['out_time_stamp']['parse_hint'];
unset($raw_row['status'], $raw_row['type']);
} elseif (!isset($column_map['in_time_stamp']) and !isset($column_map['out_time_stamp']) and isset($column_map['in_punch_date']) and isset($column_map['in_punch_time']) and isset($column_map['out_punch_date']) and isset($column_map['out_punch_time'])) {
Debug::Text('Parsing Two punches per row with separte date/time columns...', __FILE__, __LINE__, __METHOD__, 10);
$raw_row['in_time_stamp'] = $raw_row['in_punch_date'] . ' ' . $raw_row['in_punch_time'];
$in_date_time_format = $column_map['in_punch_date']['parse_hint'] . '_' . $column_map['in_punch_time']['parse_hint'];
unset($raw_row['in_punch_date'], $raw_row['in_punch_time']);
$raw_row['out_time_stamp'] = $raw_row['out_punch_date'] . ' ' . $raw_row['out_punch_time'];
$out_date_time_format = $column_map['out_punch_date']['parse_hint'] . '_' . $column_map['out_punch_time']['parse_hint'];
unset($raw_row['out_punch_date'], $raw_row['out_punch_time']);
unset($raw_row['status'], $raw_row['type']);
} else {
$in_date_time_format = $out_date_time_format = $date_time_format = 'd-M-y_g:i A T';
}
if (isset($raw_row['in_time_stamp']) and isset($raw_row['out_time_stamp'])) {
Debug::Text('bParsing Two punches per row...', __FILE__, __LINE__, __METHOD__, 10);
$split_in_date_time_format = explode('_', $in_date_time_format);
TTDate::setDateFormat($split_in_date_time_format[0]);
TTDate::setTimeFormat($split_in_date_time_format[1]);
$raw_row['in_time_stamp'] = TTDate::parseDateTime($raw_row['in_time_stamp']);
$split_out_date_time_format = explode('_', $out_date_time_format);
TTDate::setDateFormat($split_out_date_time_format[0]);
TTDate::setTimeFormat($split_out_date_time_format[1]);
$raw_row['out_time_stamp'] = TTDate::parseDateTime($raw_row['out_time_stamp']);
}
if (!isset($raw_row['in_type']) and !isset($raw_row['out_type']) and !isset($raw_row['type']) and (!isset($raw_row['type_id']) or isset($raw_row['type_id']) and $raw_row['type_id'] == '')) {
Debug::Text('Defaulting to normal punch type...', __FILE__, __LINE__, __METHOD__, 10);
$raw_row['type_id'] = 10;
//Normal
}
if (!isset($raw_row['in_status']) and !isset($raw_row['out_status']) and !isset($raw_row['status']) and (!isset($raw_row['status_id']) or isset($raw_row['status_id']) and $raw_row['status_id'] == '')) {
Debug::Text('Defaulting to IN punch status...', __FILE__, __LINE__, __METHOD__, 10);
$raw_row['status_id'] = 10;
//IN
}
if ($this->getImportOptions('disable_rounding') == TRUE) {
$raw_row['disable_rounding'] = TRUE;
}
unset($raw_row['date'], $raw_row['time']);
Debug::Arr($raw_row, 'postParse Row: ', __FILE__, __LINE__, __METHOD__, 10);
return $raw_row;
}
示例5: testBiWeeklyC
function testBiWeeklyC()
{
// Anchor: 01-Nov-04
// Primary: 15-Nov-04
// Primary Trans: 22-Nov-04
// Secondary: 29-Nov-04
// Secondary Trans: 06-Dec-04
$ret_obj = $this->createPayPeriodSchedule(20, 1, 0, NULL, NULL, NULL, NULL, TRUE);
Debug::text('Pay Period Schedule ID: ' . $ret_obj->getId(), __FILE__, __LINE__, __METHOD__, 10);
TTDate::setTimeFormat('g:i A T');
$ret_obj->getNextPayPeriod(strtotime('03-Dec-06'));
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '04-Dec-06 12:00 AM PST', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '17-Dec-06 11:59 PM PST', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '17-Dec-06', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 25, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '18-Dec-06 12:00 AM PST', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '31-Dec-06 11:59 PM PST', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '31-Dec-06', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 26, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '01-Jan-07 12:00 AM PST', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '14-Jan-07 11:59 PM PST', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '14-Jan-07', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 1, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '15-Jan-07 12:00 AM PST', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '28-Jan-07 11:59 PM PST', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '28-Jan-07', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 2, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '29-Jan-07 12:00 AM PST', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '11-Feb-07 11:59 PM PST', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '11-Feb-07', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 3, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '12-Feb-07 12:00 AM PST', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '25-Feb-07 11:59 PM PST', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '25-Feb-07', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 4, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '26-Feb-07 12:00 AM PST', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '11-Mar-07 11:59 PM PDT', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '11-Mar-07', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 5, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '12-Mar-07 12:00 AM PDT', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '25-Mar-07 11:59 PM PDT', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '25-Mar-07', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 6, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '26-Mar-07 12:00 AM PDT', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '08-Apr-07 11:59 PM PDT', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '08-Apr-07', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 7, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '09-Apr-07 12:00 AM PDT', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '22-Apr-07 11:59 PM PDT', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '22-Apr-07', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 8, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '23-Apr-07 12:00 AM PDT', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '06-May-07 11:59 PM PDT', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '06-May-07', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 9, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '07-May-07 12:00 AM PDT', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '20-May-07 11:59 PM PDT', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '20-May-07', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 10, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '21-May-07 12:00 AM PDT', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '03-Jun-07 11:59 PM PDT', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '03-Jun-07', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 11, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '04-Jun-07 12:00 AM PDT', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '17-Jun-07 11:59 PM PDT', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '17-Jun-07', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 12, '1- Pay Period Number');
$ret_obj->getNextPayPeriod($next_end_date);
$next_end_date = $ret_obj->getNextEndDate();
$this->assertEquals(TTDate::getDate('DATE+TIME', $ret_obj->getNextStartDate()), '18-Jun-07 12:00 AM PDT', '1- Start Date');
$this->assertEquals(TTDate::getDate('DATE+TIME', $next_end_date), '01-Jul-07 11:59 PM PDT', '1- End Date');
$this->assertEquals(TTDate::getDate('DATE', $ret_obj->getNextTransactionDate()), '01-Jul-07', '1- Transaction Date');
$this->assertEquals($ret_obj->getCurrentPayPeriodNumber($ret_obj->getNextTransactionDate(), $ret_obj->getNextEndDate()), 13, '1- Pay Period Number');
//.........这里部分代码省略.........
示例6: setDateTimePreferences
function setDateTimePreferences()
{
//TTDate::setTimeZone( $this->getTimeZone() );
if ($this->setTimeZonePreferences() == FALSE) {
//In case setting the time zone failed, most likely due to MySQL timezone issues.
return FALSE;
}
TTDate::setDateFormat($this->getDateFormat());
TTDate::setTimeFormat($this->getTimeFormat());
TTDate::setTimeUnitFormat($this->getTimeUnitFormat());
return TRUE;
}