date() public static method

Formats and returns given timestamp just like php's built in date() function. e.g: $obj->date("Y-m-d H:i", time()); $obj->date("Y-m-d", time(), false, false, 'America/New_York');
Author: Sallar Kaboli
public static date ( $format, $stamp = false, $convert = null, $jalali = null, $timezone = null ) : string
$format string Acceps format string based on: php.net/date
$stamp int Unix Timestamp (Epoch Time)
$convert bool (Optional) forces convert action. pass null to use system default
$jalali bool (Optional) forces jalali conversion. pass null to use system default
$timezone string (Optional) forces a different timezone. pass null to use system default
return string Formatted input
 public function test_create()
 {
     //        $date = new Date();
     //        echo $date->date("W");
     //        $date = new jDateTime(false, true, 'Asia/Tehran');
     //        echo $date->date("z  W",time());
     //        echo $date->date("Y m d",strtotime("next week"))."<br>";
     //        echo jdate("Y m d",strtotime("next week"))."<br>";
     //        echo $date->strftime("y m d","next week");
     //       echo $date->strftime("next week", time(),true, true, 'America/New_York');
     $this->load->library("date");
     $date1 = new jDateTime(false, true, 'Asia/Tehran');
     $date2 = new jDateTime(false);
     $date1->strftime("now");
     $date2->strftime("tomorrow");
     echo $date1->strftime("%s");
     var_dump($date1->date() == $date2->date());
     var_dump($date1 < $date2);
     var_dump($date1 > $date2);
 }
Example #2
0
 public static function date()
 {
     $date = new jDateTime(true, true, 'Asia/Tehran');
     return $date->date("Y-m-d", false, false);
 }
Example #3
0
File: index.php Project: VSG24/ccms
    } else {
        $register_status = 'no';
    }
    $query = "UPDATE c_options SET option_value = '{$register_status}' WHERE option_name = 'register_open'";
    $res = $conn->query($query);
    dbQueryCheck($res, $conn);
    //
    if (isset($_POST['conf_mail'])) {
        $conf_mail = 'yes';
    } else {
        $conf_mail = 'no';
    }
    $query = "UPDATE c_options SET option_value = '{$conf_mail}' WHERE option_name = 'send_conf_mail'";
    $res = $conn->query($query);
    dbQueryCheck($res, $conn);
    $datetime = jDateTime::date('Y-m-d', false, null, false);
    $query = "UPDATE c_options SET option_value = '{$datetime}' WHERE option_name = 'installation_date'";
    $res = $conn->query($query);
    dbQueryCheck($res, $conn);
    ob_end_clean();
    redirectTo('index.php?switch=4&hash=' . $hash);
}
?>
    <?php 
if (!isset($_GET['switch'])) {
    ?>
        <div class="col-xs-12 col-sm-12 col-md-6 co-lg-6 col-md-offset-2 div_white_left">
            <div style="text-align: center; padding: 5%;">
                Welcome to ccms installation script.<br>Just a few steps and your website will be online.
                <br><br>
                Please <strong>do not</strong> refresh any page or use back button on your browser during installation.
 function submit_to_db()
 {
     if (!defined('DOKU_INC')) {
         define('DOKU_INC', dirname(__FILE__) . '/../../../../');
         include_once DOKU_INC . 'inc/init.php';
         include_once DOKU_INC . 'inc/plugin.php';
     }
     global $conf;
     include_once dirname(__FILE__) . '/helper/jdatetime.class.php';
     $pdate = new jDateTime(false, true, 'Asia/Tehran');
     date_default_timezone_set('Asia/Tehran');
     $query = 'INSERT INTO submissions VALUES (NULL,"' . time() . '","' . $_POST['problem_name'] . '","' . $_POST['user'] . '","' . $_POST['type'] . '",' . $_POST['status_code'] . ')';
     $db = new SQLite3(DBFILE);
     $db->exec($query);
     $id = $db->lastInsertRowID();
     $result_id_query = 'SELECT COUNT(*) FROM submissions WHERE problem_name = "' . $_POST['problem_name'] . '"AND username="******"';
     $row_number = $db->querySingle($result_id_query);
     if ($conf['lang'] == "fa") {
         $date = $pdate->date("l j F Y H:i:s");
     } else {
         $date = date('l j F Y H:i:s');
     }
     if ($_POST['type'] === "output-only") {
         $result = array('date' => $date, 'row_number' => $row_number);
     } elseif ($_POST['type'] === "test-case") {
         $test_case_query = 'INSERT INTO submission_test_case VALUES (' . $id . ',"' . $_POST['language'] . '",' . '0,"' . $_POST['runtime'] . '")';
         $db->exec($test_case_query);
         $result = array('date' => $date, 'row_number' => $row_number, 'id' => $id);
     }
     return $result;
 }
Example #5
0
 public static function date($format, $stamp = false, $convert = null, $jalali = null, $timezone = null)
 {
     return jDateTime::date($format, $stamp, $convert, $jalali, $timezone);
 }
Example #6
0
    /**
     *
     * @param Controller $controller
     */
    public function actionVoucher($controller)
    {
        $message = $controller->getUser()->message();
        if (isset($_POST['remove'])) {
            foreach ($_POST['delete'] as $value) {
                $sql = CShop::app()->getDb()->prepare(QueryBuilder::getInstance()->delete('voucher')->where('id = ?'));
                $sql->execute(array($value));
            }
            $message['content'] = 'تغییرات با موفقیت ذخیره شد';
            $message['type'] = 'success';
            $controller->getUser()->message($message);
            CShop::app()->redirect($_SERVER['REQUEST_URI']);
        }
        $sql = CShop::app()->getDb()->query(QueryBuilder::getInstance()->select()->from('voucher'));
        $content = '<div class="title">مدیریت کد های تخفیف</div>
						<div class="content">
						<form action="" method="post">
						<table>
						<tr>
							<th>ردیف</th>
							<th>کد</th>
							<th>ارزش</th>
							<th>زمان پایان</th>
							<th>تعداد باقی مانده</th>
							<th>مدیریت</th>
							<th><a href="#" onclick="check(this)">انتخاب</a></th>
						</tr>';
        $i = 1;
        while ($item = $sql->fetch()) {
            $content .= '<tr>';
            $content .= '<td>' . $i++ . '</td>';
            $content .= '<td>' . $item['code'] . '</td>';
            $content .= '<td>' . $item['value'] . '%</td>';
            $content .= '<td>' . jDateTime::date(CShop::app()->systemConfig()->timeformat, $item['paymenttime'] ? $item['paymenttime'] : $item['time']) . '</td>';
            $content .= '<td>' . $item['maxuse'] . '</td>';
            $content .= '<td><a href="' . self::getActionLink('editvoucher', $this->id) . '&vid=' . $item['id'] . '">ویرایش</a></td>';
            $content .= '<td><input type="checkbox" name="delete[]" value="' . $item['id'] . '"></td>';
            $content .= '</tr>';
        }
        $content .= '</table><div style="text-align: left"><input type="submit" value="ذخیره" name="update"><input type="submit" value="حذف" name="remove"></div></form></div>';
        $controller->renderWithContent($content, array('message' => $message));
    }
Example #7
0
<?php

//Include
require_once dirname(__FILE__) . '/jdatetime.class.php';
//Just add routine html tags and encoding the settings to view Persian characters correctly.
echo "<html>";
echo "<head>";
echo "<meta charset='utf-8'>";
echo "</head>";
echo "<body>";
//Init
$date = new jDateTime(true, true, 'Asia/Tehran');
echo $date->date("l j F Y H:i");
// Outputs: پنجشنبه ۱۵ اردیبهشت ۱۳۹۰ ۰۰:۰۰
echo "<br />\n";
echo $date->date("Y-m-d", false, false);
// Outputs: 1390-02-15
echo "<br />\n";
echo $date->date("Y-m-d", false, false, false);
//Outputs: 2011-05-05
//Or you could just use: $date->gDate("Y-m-d");
//Same as above
echo "<br />\n";
echo $date->date("l j F Y H:i T", false, null, null, 'America/New_York');
//چهارشنبه ۱۴ اردیبهشت ۱۳۹۰ ۱۵:۳۰ EDT
echo "<br />\n";
echo "<br />\n";
$time = $date->mktime(0, 0, 0, 10, 2, 1368);
//630361800
echo $date->date("l Y/m/d", $time);
//Outputs: شنبه ۱۳۶۸/۱۰/۰۲
<?php

//Include
require_once dirname(__FILE__) . '/jdatetime.class.php';
//Just adding routine html tags and setting encoding to view Persian characters correctly.
echo "<html>";
echo "<head>";
echo "<meta charset='utf-8'>";
echo "</head>";
echo "<body>";
date_default_timezone_set('Asia/Tehran');
echo jDateTime::date('l j F Y H:i');
echo "<br />";
echo jDateTime::date('Y-m-d', false, false);
echo "<br />";
echo jDateTime::date('Y-m-d', false, false, false);
echo "<br />";
echo jDateTime::date("l j F Y H:i T", false, null, null, 'America/New_York');
//Just adding routine html tags.
echo "</body>";
echo "</html>";
 function jdate($format, $timestamp = 'now', $persian_number = true)
 {
     $jdate = new jDateTime(true, true, 'Asia/Tehran');
     return $jdate->date($format, $timestamp, $persian_number);
 }
Example #10
0
echo "<br />\n";
echo $date->date("l M jS, Y", $time, false, false);
//Outputs: Saturday Dec 23rd, 1989
echo "<br />\n";
echo "<br />\n";
$time2 = $date->mktime(0, 0, 0, 1, 1, 2010, false, 'America/New_York');
//1262322000
echo $date->date("c", $time2, false, false, 'America/New_York');
//Outputs: 2010-01-01T00:00:00-05:00
echo "<br />\n";
//Lets see whens its January 1st in New York, What Time is it in Berlin?
echo $date->date("c", $time2, false, false, 'Europe/Berlin');
//Outputs: 2010-01-01T06:00:00+01:0
//Or Iran in Native Time?
echo "<br />\n";
echo $date->date("c", $time2, false, true, 'Asia/Tehran');
//Outputs: 1388-10-11T08:30:00+03:30
echo "<br />\n";
// Dari month names
$date = new jDateTime(true, true, 'Asia/Tehran', 'dari');
echo $date->date("l j F Y H:i");
// Outputs: پنجشنبه ۱۵ اردیبهشت ۱۳۹۰ ۰۰:۰۰
echo "<br />\n";
// Pashtu month names
$date = new jDateTime(true, true, 'Asia/Tehran', 'pashtu');
echo $date->date("l j F Y H:i");
// Outputs: پنجشنبه ۱۵ اردیبهشت ۱۳۹۰ ۰۰:۰۰
echo "<br />\n";
//Just adding routine html tags.
echo "</body>";
echo "</html>";
 public function convert_time($timestamp)
 {
     global $conf;
     include_once dirname(__FILE__) . '/jdatetime.class.php';
     $pdate = new jDateTime(false, true, 'Asia/Tehran');
     if ($conf['lang'] == "fa") {
         return $pdate->date("l j F Y H:i:s", $timestamp);
     } else {
         return date('l j F Y H:i:s', $timestamp);
     }
 }
Example #12
0
	<table>
	<tr>
		<th>ردیف</th>
		<th>تاریخ</th>
		<th>مبلغ</th>
		<th>وضعیت</th>
		<th>مدیریت</th>
		<th><a href="#" onclick="check(this)">انتخاب</a></th>
	</tr>
		<?php 
$td = $th = '';
$i = 1 + $this->pagination->offset();
foreach ($items as $item) {
    echo '<tr>';
    echo '<td>' . $i++ . '</td>';
    echo '<td>' . jDateTime::date(CShop::app()->systemConfig()->timeformat, $item['paymenttime'] ? $item['paymenttime'] : $item['requesttime']) . '</td>';
    echo '<td>' . $item['amount'] . '</td>';
    echo '<td>';
    echo $item['status'] == Application::STATUS_COMPLETE ? 'پرداخت شده' : 'پرداخت نشده';
    echo '</td>';
    echo '<td><a href="viewpayment.php?id=' . $item['id'] . '">مشاهده</a></td>';
    echo '<td><input type="checkbox" name="delete[]" value="' . $item['id'] . '"></td>';
    echo '</tr>';
}
?>
	</table>
	<?php 
if ($this->pagination->total) {
    ?>
	<div class="pagination">
	<?php