Ejemplo n.º 1
0
    public static function datetime($args = array())
    {
        $name = self::get_name($args);
        $value = isset($args['value']) ? $args['value'] : '';
        $field_class = isset($args['field_class']) ? trim($args['field_class']) : '';
        $label = isset($args['label']) ? $args['label'] : '';
        $date_format = isset($args['date_format']) ? $args['date_format'] : SB_Option::get_date_format();
        if (!empty($value)) {
            $value = date($date_format, $value);
        }
        if ($value == 0) {
            $value = '';
        }
        $field_class = SB_PHP::add_string_with_space_before($field_class, 'sb-datetime');
        $current = isset($args['current']) ? $args['current'] : false;
        if ($current && empty($value)) {
            $value = date($date_format);
        }
        ?>
        <p>
            <label for="<?php 
        echo esc_attr($name);
        ?>
"><?php 
        echo $label;
        ?>
:</label>
            <input type="text" id="<?php 
        echo esc_attr($name);
        ?>
" name="<?php 
        echo esc_attr($name);
        ?>
" value="<?php 
        echo $value;
        ?>
" class="<?php 
        echo $field_class;
        ?>
" placeholder="<?php 
        echo $date_format;
        ?>
" autocomplete="off">
        </p>
    <?php 
    }
Ejemplo n.º 2
0
 public static function get_the_date()
 {
     $post_date = get_the_date();
     if (empty($post_date)) {
         $post_id = get_the_ID();
         $post = get_post($post_id);
         $post_date = $post->post_date_gmt;
         $post_date = date(SB_Option::get_date_format(), strtotime($post_date));
     }
     return $post_date;
 }