2

I have a php file which I will later change into the form of an HTML file, which be current constraints are: - Date format using Javascript.

Her script like the following snippet:

<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>

please help me to overcome it. I want to run a php script in javascript that is being subordinated.

example:

<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>

Please help, Regards

3 Answers 3

2

this can all be done in 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>
Sign up to request clarification or add additional context in comments.

Comments

0

Use strtotime() and date():

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

(see strtotime and date docs on the PHP site).

Comments

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');
?>

See all date time formats: http://www.php.net/manual/en/datetime.formats.php

1 Comment

thank you so much for providing input, but my intent was to change the date format in php into javascript.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.