当前位置: 首页>>代码示例>>PHP>>正文


PHP userdate函数代码示例

本文整理汇总了PHP中userdate函数的典型用法代码示例。如果您正苦于以下问题:PHP userdate函数的具体用法?PHP userdate怎么用?PHP userdate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了userdate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: test_postdate

 /**
  * Test for the forum email renderable postdate.
  *
  * @dataProvider postdate_provider
  *
  * @param array  $globalconfig      The configuration to set on $CFG
  * @param array  $forumconfig       The configuration for this forum
  * @param array  $postconfig        The configuration for this post
  * @param array  $discussionconfig  The configuration for this discussion
  * @param string $expectation       The expected date
  */
 public function test_postdate($globalconfig, $forumconfig, $postconfig, $discussionconfig, $expectation)
 {
     global $CFG, $DB;
     $this->resetAfterTest(true);
     // Apply the global configuration.
     foreach ($globalconfig as $key => $value) {
         $CFG->{$key} = $value;
     }
     // Create the fixture.
     $user = $this->getDataGenerator()->create_user();
     $course = $this->getDataGenerator()->create_course();
     $forum = $this->getDataGenerator()->create_module('forum', (object) array('course' => $course->id));
     $cm = get_coursemodule_from_instance('forum', $forum->id, $course->id, false, MUST_EXIST);
     $this->getDataGenerator()->enrol_user($user->id, $course->id);
     // Create a new discussion.
     $discussion = $this->getDataGenerator()->get_plugin_generator('mod_forum')->create_discussion((object) array_merge($discussionconfig, array('course' => $course->id, 'forum' => $forum->id, 'userid' => $user->id)));
     // Apply the discussion configuration.
     // Some settings are ignored by the generator and must be set manually.
     $discussion = $DB->get_record('forum_discussions', array('id' => $discussion->id));
     foreach ($discussionconfig as $key => $value) {
         $discussion->{$key} = $value;
     }
     $DB->update_record('forum_discussions', $discussion);
     // Apply the post configuration.
     // Some settings are ignored by the generator and must be set manually.
     $post = $DB->get_record('forum_posts', array('discussion' => $discussion->id));
     foreach ($postconfig as $key => $value) {
         $post->{$key} = $value;
     }
     $DB->update_record('forum_posts', $post);
     // Create the renderable.
     $renderable = new mod_forum\output\forum_post_email($course, $cm, $forum, $discussion, $post, $user, $user, true);
     // Check the postdate matches our expectations.
     $this->assertEquals(userdate($expectation, "", \core_date::get_user_timezone($user)), $renderable->get_postdate());
 }
开发者ID:evltuma,项目名称:moodle,代码行数:46,代码来源:output_email_test.php

示例2: get_comments

 /**
  * Return comments by pages
  * @param int $page
  * @return mixed
  */
 function get_comments($page)
 {
     global $DB, $CFG, $USER;
     $params = array();
     if ($page == 0) {
         $start = 0;
     } else {
         $start = $page * $this->perpage;
     }
     $sql = "SELECT c.id, c.contextid, c.itemid, c.commentarea, c.userid, c.content, u.firstname, u.lastname, c.timecreated\n            FROM {comments} c, {user} u\n            WHERE u.id=c.userid ORDER BY c.timecreated ASC";
     $comments = array();
     $formatoptions = array('overflowdiv' => true);
     if ($records = $DB->get_records_sql($sql, array(), $start, $this->perpage)) {
         foreach ($records as $item) {
             $item->fullname = fullname($item);
             $item->time = userdate($item->timecreated);
             $item->content = format_text($item->content, FORMAT_MOODLE, $formatoptions);
             $comments[] = $item;
             unset($item->firstname);
             unset($item->lastname);
             unset($item->timecreated);
         }
     }
     return $comments;
 }
开发者ID:vuchannguyen,项目名称:web,代码行数:30,代码来源:locallib.php

示例3: readquestions

 protected function readquestions($lines)
 {
     // For this class the method has been simplified as
     // there can never be more than one question for a
     // multianswer import
     $questions = array();
     $questiontext = array();
     $questiontext['text'] = implode('', $lines);
     $questiontext['format'] = 0;
     $questiontext['itemid'] = '';
     $question = qtype_multianswer_extract_question($questiontext);
     $question->questiontext = $question->questiontext['text'];
     $question->questiontextformat = 0;
     $question->qtype = MULTIANSWER;
     $question->generalfeedback = '';
     $question->course = $this->course;
     if (!empty($question)) {
         $name = html_to_text(implode(' ', $lines));
         $name = preg_replace('/{[^}]*}/', '', $name);
         $name = trim($name);
         if ($name) {
             $question->name = shorten_text($name, 45);
         } else {
             // We need some name, so use the current time, since that will be
             // reasonably unique.
             $question->name = userdate(time());
         }
         $questions[] = $question;
     }
     return $questions;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:31,代码来源:format.php

示例4: block_exabis_eportfolio_print_extcomments

function block_exabis_eportfolio_print_extcomments($itemid)
{
    $stredit = get_string('edit');
    $strdelete = get_string('delete');
    $comments = get_records("block_exabeporitemcomm", "itemid", $itemid, 'timemodified DESC');
    if (!$comments) {
        return;
    }
    foreach ($comments as $comment) {
        $user = get_record('user', 'id', $comment->userid);
        echo '<table cellspacing="0" class="forumpost blogpost blog" width="100%">';
        echo '<tr class="header"><td class="picture left">';
        print_user_picture($comment->userid, SITEID, $user->picture);
        echo '</td>';
        echo '<td class="topic starter"><div class="author">';
        $fullname = fullname($user, $comment->userid);
        $by = new object();
        $by->name = $fullname;
        $by->date = userdate($comment->timemodified);
        print_string('bynameondate', 'forum', $by);
        echo '</div></td></tr>';
        echo '<tr><td class="left side">';
        echo '</td><td class="content">' . "\n";
        echo format_text($comment->entry);
        echo '</td></tr></table>' . "\n\n";
    }
}
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:27,代码来源:externlib.php

示例5: definition

 public function definition()
 {
     global $CFG, $USER;
     $mform =& $this->_form;
     $course = $this->_customdata['course'];
     $cm = $this->_customdata['cm'];
     $modcontext = $this->_customdata['modcontext'];
     $attforsession = $this->_customdata['session'];
     $attblock = $this->_customdata['attendance'];
     $statuses = $attblock->get_statuses();
     $mform->addElement('hidden', 'sessid', null);
     $mform->setType('sessid', PARAM_INT);
     $mform->setConstant('sessid', $attforsession->id);
     $mform->addElement('hidden', 'sesskey', null);
     $mform->setType('sesskey', PARAM_INT);
     $mform->setConstant('sesskey', sesskey());
     // Set a title as the date and time of the session.
     $sesstiontitle = userdate($attforsession->sessdate, get_string('strftimedate')) . ' ' . userdate($attforsession->sessdate, get_string('strftimehm', 'mod_attendance'));
     $mform->addElement('header', 'session', $sesstiontitle);
     // If a session description is set display it.
     if (!empty($attforsession->description)) {
         $mform->addElement('html', $attforsession->description);
     }
     // Create radio buttons for setting the attendance status.
     $radioarray = array();
     foreach ($statuses as $status) {
         $radioarray[] =& $mform->createElement('radio', 'status', '', $status->description, $status->id, array());
     }
     // Add the radio buttons as a control with the user's name in front.
     $mform->addGroup($radioarray, 'statusarray', $USER->firstname . ' ' . $USER->lastname . ':', array(''), false);
     $mform->addRule('statusarray', get_string('attendancenotset', 'attendance'), 'required', '', 'client', false, false);
     $this->add_action_buttons();
 }
开发者ID:webcursosuai,项目名称:moodle-mod_attendance,代码行数:33,代码来源:student_attenance_form.php

示例6: _createElements

 function _createElements()
 {
     $this->_elements = array();
     for ($i = 1; $i <= 31; $i++) {
         $days[$i] = $i;
     }
     for ($i = 1; $i <= 12; $i++) {
         $months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), "%B");
     }
     for ($i = $this->_options['startyear']; $i <= $this->_options['stopyear']; $i++) {
         $years[$i] = $i;
     }
     $this->_elements[] =& MoodleQuickForm::createElement('select', 'day', get_string('day', 'form'), $days, $this->getAttributes(), true);
     $this->_elements[] =& MoodleQuickForm::createElement('select', 'month', get_string('month', 'form'), $months, $this->getAttributes(), true);
     $this->_elements[] =& MoodleQuickForm::createElement('select', 'year', get_string('year', 'form'), $years, $this->getAttributes(), true);
     // If optional we add a checkbox which the user can use to turn if on
     if ($this->_options['optional']) {
         $this->_elements[] =& MoodleQuickForm::createElement('checkbox', 'off', null, get_string('disable'), $this->getAttributes(), true);
     }
     foreach ($this->_elements as $element) {
         if (method_exists($element, 'setHiddenLabel')) {
             $element->setHiddenLabel(true);
         }
     }
 }
开发者ID:JackCanada,项目名称:moodle-hacks,代码行数:25,代码来源:dateselector.php

示例7: execute

 function execute($data, $row, $user, $courseid, $starttime = 0, $endtime = 0)
 {
     global $DB, $CFG;
     if ($cm = $DB->get_record('course_modules', array('id' => $data->cmid))) {
         $mod = $DB->get_record('modules', array('id' => $cm->module));
         if ($instance = $DB->get_record("{$mod->name}", array('id' => $cm->instance))) {
             $libfile = "{$CFG->dirroot}/mod/{$mod->name}/lib.php";
             if (file_exists($libfile)) {
                 require_once $libfile;
                 $user_outline = $mod->name . "_user_outline";
                 if (function_exists($user_outline)) {
                     if ($course = $DB->get_record('course', array('id' => $this->report->courseid))) {
                         $result = $user_outline($course, $row, $mod, $instance);
                         if ($result) {
                             $returndata = '';
                             if (isset($result->info)) {
                                 $returndata .= $result->info . ' ';
                             }
                             if ((!isset($data->donotshowtime) || !$data->donotshowtime) && !empty($result->time)) {
                                 $returndata .= userdate($result->time);
                             }
                             return $returndata;
                         }
                     }
                 }
             }
         }
     }
     return '';
 }
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:30,代码来源:plugin.class.php

示例8: get_cells

    public function get_cells() {
        $this->init_cells();
        foreach ($this->reportdata->sessions as $sess) {
            if (array_key_exists($sess->id, $this->reportdata->sessionslog[$this->user->id])) {
                $statusid = $this->reportdata->sessionslog[$this->user->id][$sess->id]->statusid;
                if (array_key_exists($statusid, $this->reportdata->statuses)) {
                    $this->construct_existing_status_cell($this->reportdata->statuses[$statusid]->acronym);
                } else {
                    $this->construct_hidden_status_cell($this->reportdata->allstatuses[$statusid]->acronym);
                }
            } else {
                if ($this->user->enrolmentstart > $sess->sessdate) {
                    $starttext = get_string('enrolmentstart', 'local_attendance', userdate($this->user->enrolmentstart, '%d.%m.%Y'));
                    $this->construct_enrolments_info_cell($starttext);
                } else if ($this->user->enrolmentend and $this->user->enrolmentend < $sess->sessdate) {
                    $endtext = get_string('enrolmentend', 'local_attendance', userdate($this->user->enrolmentend, '%d.%m.%Y'));
                    $this->construct_enrolments_info_cell($endtext);
                } else if (!$this->user->enrolmentend and $this->user->enrolmentstatus == ENROL_USER_SUSPENDED) {
                    // No enrolmentend and ENROL_USER_SUSPENDED.
                    $suspendext = get_string('enrolmentsuspended', 'local_attendance', userdate($this->user->enrolmentend, '%d.%m.%Y'));
                    $this->construct_enrolments_info_cell($suspendext);
                } else {
                    if ($sess->groupid == 0 or array_key_exists($sess->groupid, $this->reportdata->usersgroups[$this->user->id])) {
                        $this->construct_not_taken_cell('?');
                    } else {
                        $this->construct_not_existing_for_user_session_cell('');
                    }
                }
            }
        }
        $this->finalize_cells();

        return $this->cells;
    }
开发者ID:anilch,项目名称:Personel,代码行数:34,代码来源:renderhelpers.php

示例9: definition

 public function definition()
 {
     $mform =& $this->_form;
     $mform->addElement('header', 'addactivity', get_string('addactivity', 'report_cpd'));
     $mform->addElement('hidden', 'cpdyearid', $this->_customdata['cpdyearid']);
     $mform->addElement('hidden', 'process', '1');
     if ($this->_customdata['cpdid']) {
         // This updates a CPD Report
         $mform->addElement('hidden', 'id', $this->_customdata['cpdid']);
     }
     $mform->addElement('textarea', 'objective', get_string('objective', 'report_cpd'), array('rows' => '2', 'cols' => '40'));
     $mform->addElement('textarea', 'development_need', get_string('developmentneed', 'report_cpd'), array('rows' => '2', 'cols' => '40'));
     if ($this->_customdata['activity_types']) {
         $mform->addElement('select', 'activitytypeid', get_string('activitytype', 'report_cpd'), $this->_customdata['activity_types']);
     }
     $mform->addElement('textarea', 'activity', get_string('activityplanned', 'report_cpd'), array('rows' => '2', 'cols' => '40'));
     // Get CPD start and end years
     $startyear = date('Y') - 5;
     $endyear = date('Y') + 5;
     if ($this->_customdata['cpdyear']) {
         $startyear = date('Y', $this->_customdata['cpdyear']->startdate);
         $endyear = date('Y', $this->_customdata['cpdyear']->enddate);
     }
     for ($i = 1; $i <= 31; $i++) {
         $days[$i] = $i;
     }
     for ($i = 1; $i <= 12; $i++) {
         $months[$i] = userdate(gmmktime(12, 0, 0, $i, 15, 2000), "%B");
     }
     for ($i = $startyear; $i <= $endyear; $i++) {
         $years[$i] = $i;
     }
     $startdate[] = $mform->createElement('select', 'startdate[d]', '', $days);
     $startdate[] = $mform->createElement('select', 'startdate[m]', '', $months);
     $startdate[] = $mform->createElement('select', 'startdate[Y]', '', $years);
     $mform->addGroup($startdate, 'startdate', get_string('datestart', 'report_cpd'), array(' '), false);
     $duedate[] = $mform->createElement('select', 'duedate[d]', '', $days);
     $duedate[] = $mform->createElement('select', 'duedate[m]', '', $months);
     $duedate[] = $mform->createElement('select', 'duedate[Y]', '', $years);
     $mform->addGroup($duedate, 'duedate', get_string('dateend', 'report_cpd'), array(' '), false);
     if ($this->_customdata['statuses']) {
         $mform->addElement('select', 'statusid', get_string('status', 'report_cpd'), $this->_customdata['statuses']);
     }
     $hours = null;
     $minutes = null;
     for ($i = 1; $i <= 20; $i++) {
         $hours[$i] = $i;
     }
     for ($i = 15; $i <= 45; $i += 15) {
         $minutes[$i] = $i;
     }
     $timetaken[] = $mform->createElement('select', 'timetaken[hours]', '', array('' => '--') + $hours);
     $timetaken[] = $mform->createElement('select', 'timetaken[minutes]', '', array('' => '--') + $minutes);
     $mform->addGroup($timetaken, 'timetaken', get_string('timetaken', 'report_cpd'), ':', false);
     $buttonarray[] = $mform->createElement('submit', 'submitbutton', get_string('update'));
     $buttonarray[] = $mform->createElement('reset', '', get_string('clear', 'report_cpd'));
     $mform->addGroup($buttonarray, 'buttonar', '', array(' '), false);
     $mform->closeHeaderBefore('buttonar');
     //$mform->addRule('objective', 'Please enter an objective.', 'required', null, 'client');
 }
开发者ID:rtsfc,项目名称:moodle-report_cpd,代码行数:60,代码来源:edit_activity_form.php

示例10: get_comments

 /**
  * Return comments by pages
  *
  * @global moodle_database $DB
  * @param int $page
  * @return array An array of comments
  */
 function get_comments($page)
 {
     global $DB;
     if ($page == 0) {
         $start = 0;
     } else {
         $start = $page * $this->perpage;
     }
     $comments = array();
     $sql = "SELECT c.id, c.contextid, c.itemid, c.commentarea, c.userid, c.content, u.firstname, u.lastname, c.timecreated\n                  FROM {comments} c\n                  JOIN {user} u\n                       ON u.id=c.userid\n              ORDER BY c.timecreated ASC";
     $rs = $DB->get_recordset_sql($sql, null, $start, $this->perpage);
     $formatoptions = array('overflowdiv' => true);
     foreach ($rs as $item) {
         // Set calculated fields
         $item->fullname = fullname($item);
         $item->time = userdate($item->timecreated);
         $item->content = format_text($item->content, FORMAT_MOODLE, $formatoptions);
         // Unset fields not related to the comment
         unset($item->firstname);
         unset($item->lastname);
         unset($item->timecreated);
         // Record the comment
         $comments[] = $item;
     }
     $rs->close();
     return $comments;
 }
开发者ID:nmicha,项目名称:moodle,代码行数:34,代码来源:locallib.php

示例11: display_browse_field

 function display_browse_field($recordid, $template)
 {
     global $CFG;
     if ($content = get_field('data_content', 'content', 'fieldid', $this->field->id, 'recordid', $recordid)) {
         return userdate($content, get_string('strftimedate'), 0);
     }
 }
开发者ID:veritech,项目名称:pare-project,代码行数:7,代码来源:field.class.php

示例12: block_campusclash_print_page

function block_campusclash_print_page($campusclash, $return = false)
{
    //Add Page Title
    global $OUTPUT, $COURSE;
    $display = $OUTPUT->heading($campusclash->pagetitle);
    //Open a box
    $display .= $OUTPUT->box_start();
    //Display the Date
    if ($campusclash->displaydate) {
        $display .= html_writer::start_tag('div', array('class' => 'displaydate'));
        $display .= userdate($campusclash->displaydate);
        $display .= html_writer::end_tag('div');
    }
    //Display Text
    $display .= clean_text($campusclash->displaytext);
    //close the box
    $display .= $OUTPUT->box_end();
    //Display the Picture
    if ($campusclash->displaypicture) {
        $display .= $OUTPUT->box_start();
        $images = block_campusclash_images();
        $display .= $images[$campusclash->picture];
        $display .= html_writer::start_tag('p');
        $display .= clean_text($campusclash->description);
        $display .= html_writer::end_tag('p');
        $display .= $OUTPUT->box_end();
    }
    //Check to ensure that it was set before trying to output it
    if ($return) {
        return $display;
    } else {
        echo $display;
    }
}
开发者ID:jpablonc94,项目名称:campusclashGithub,代码行数:34,代码来源:lib.php

示例13: col_timecreated

 /**
  * This function is called for each data row to allow processing of the
  * username value.
  *
  * @param object $values Contains object with all the values of record.
  * @return $string Return username with link to profile or username only
  *     when downloading.
  */
 function col_timecreated($values)
 {
     if ($values->timecreated > 0) {
         return userdate($values->timecreated);
     }
     return '';
 }
开发者ID:375michael40veit,项目名称:moodle-mod_booking,代码行数:15,代码来源:unbooked_users.php

示例14: glossary_show_entry_faq

function glossary_show_entry_faq($course, $cm, $glossary, $entry, $mode = "", $hook = "", $printicons = 1, $aliases = true)
{
    global $USER;
    if ($entry) {
        echo '<table class="glossarypost faq" cellspacing="0">';
        echo '<tr valign="top">';
        echo '<th class="entryheader">';
        $entry->course = $course->id;
        echo '<div class="concept">' . get_string('question', 'glossary') . ': ';
        glossary_print_entry_concept($entry);
        echo '</div>';
        echo '<span class="time">(' . get_string('lastedited') . ': ' . userdate($entry->timemodified) . ')</span>';
        echo '</th>';
        echo '<td class="entryattachment">';
        glossary_print_entry_approval($cm, $entry, $mode);
        echo '</td>';
        echo '</tr>';
        echo "\n<tr>";
        echo '<td colspan="2" class="entry">';
        echo '<b>' . get_string('answer', 'glossary') . ':</b> ';
        glossary_print_entry_definition($entry, $glossary, $cm);
        glossary_print_entry_attachment($entry, $cm, 'html');
        echo '</td></tr>';
        echo '<tr valign="top"><td colspan="3" class="entrylowersection">';
        glossary_print_entry_lower_section($course, $cm, $glossary, $entry, $mode, $hook, $printicons, $aliases);
        echo '</td></tr></table>';
    } else {
        echo '<div style="text-align:center">';
        print_string('noentry', 'glossary');
        echo '</div>';
    }
}
开发者ID:evltuma,项目名称:moodle,代码行数:32,代码来源:faq_format.php

示例15: definition

 public function definition()
 {
     global $CFG, $OUTPUT, $DB, $USER;
     $publication =& $this->_customdata['publication'];
     $this->instance = $publication->get_instance();
     $userids =& $this->_customdata['userids'];
     $mform = $this->_form;
     if ($publication->get_instance()->allowsubmissionsfromdate) {
         $mform->addElement('static', 'fromdate', get_string('allowsubmissionsfromdate', 'publication'), userdate($publication->get_instance()->allowsubmissionsfromdate));
     }
     if ($publication->get_instance()->duedate) {
         $mform->addElement('static', 'duedate', get_string('duedate', 'publication'), userdate($publication->get_instance()->duedate));
         $finaldate = $publication->get_instance()->duedate;
     }
     $mform->addElement('date_time_selector', 'extensionduedate', get_string('extensionduedate', 'publication'), array('optional' => true));
     $mform->setDefault('extensionduedate', $finaldate);
     if (count($userids) == 1) {
         $extensionduedate = $publication->user_extensionduedate($userids[0]);
         if ($extensionduedate) {
             $mform->setDefault('extensionduedate', $extensionduedate);
         }
     }
     $mform->addElement('hidden', 'id', $publication->get_coursemodule()->id);
     $mform->setType('id', PARAM_INT);
     foreach ($userids as $idx => $userid) {
         $mform->addElement('hidden', 'userids[' . $idx . ']', $userid);
         $mform->setType('userids[' . $idx . ']', PARAM_INT);
     }
     $this->add_action_buttons(true, get_string('save_changes', 'publication'));
 }
开发者ID:Kathrin84,项目名称:moodle-mod_publication,代码行数:30,代码来源:mod_publication_grantextension_form.php


注:本文中的userdate函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。