2

我有一个 php 文件,稍后我将其更改为 HTML 文件的形式,当前的约束是: - 使用 Javascript 的日期格式。

她的脚本如下所示:

<script type="text/javascript" src="js/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="js/script.js"></script>
    <?php
        /* Set start and end dates here */
        $startDate  = strtotime("15 August 2012 12:00:00");
        $endDate    = strtotime("15 November 2012 12:00:00");
        /* /Set start and end dates here */
    ?>
    <script type="text/javascript">
        $(document).ready(function(){
            JBCountDown({
                secondsColor : "#ffdc50",
                minutesColor : "#9cdb7d",
                hoursColor   : "#378cff",
                daysColor    : "#ff6565",

                startDate   : "<?php echo $startDate; ?>",
                endDate     : "<?php echo $endDate; ?>",
                now         : "<?php echo strtotime('now'); ?>",
                seconds     : "<?php echo date("s"); ?>"
            });
        });
    </script>

请帮助我克服它。我想在从属的 javascript 中运行一个 php 脚本。

例子:

<script type="text/javascript">
        $(document).ready(function(){
            JBCountDown({
                secondsColor : "#ffdc50",
                minutesColor : "#9cdb7d",
                hoursColor   : "#378cff",
                daysColor    : "#ff6565",

                startDate   : startDate,  //format time in JS
                endDate     : endDate,  //format time in JS
                now         : strtotime('now'),  //format time in JS
                seconds     : date("s")
            });
        });
    </script>

请帮助,问候

4

3 回答 3

2

这一切都可以在javascript中完成。

<script type="text/javascript">

        $(document).ready(function(){

        //http://www.convert-unix-time.com/

        var unix = Math.round(+new Date()/1000);  //unix timestamp for todays date
        //alert(unix);

            JBCountDown({
                secondsColor : "#ffdc50",
                secondsGlow  : "none",

                minutesColor : "#9cdb7d",
                minutesGlow  : "none",

                hoursColor   : "#378cff",
                hoursGlow    : "none",

                daysColor    : "#ff6565",
                daysGlow     : "none",

                startDate   : "1362096000 ", //unix timestamp for ' Friday 1st March 2013 12:00:00 AM'
                endDate     : "1373328000", //unix timestamp for 'Tuesday 9th July 2013 01:00:00 AM'
                now         : unix,
                seconds     : unix % 60 //unix timestamp for seconds in realtime
            });
        });
    </script>
于 2013-05-17T02:41:56.800 回答
0

使用 strtotime() 和 date():

$originalDate = "2010-03-21";
$newDate = date("d-m-Y", strtotime($originalDate));

(请参阅PHP 站点上的strtotimedate文档)。

于 2013-02-06T12:14:44.117 回答
0
<?php
        /* Set start and end dates here */
$startDate  = new DateTime("15 August 2012 12:00:00");
$endDate    = new DateTime("15 November 2012 12:00:00");
/* /Set start and end dates here */

print $startDate->format('FORMAT');
?>

查看所有日期时间格式:http ://www.php.net/manual/en/datetime.formats.php

于 2013-02-06T12:14:58.847 回答