Having some problems with a javascript code, when i try to pass a php string to it, it's a date timer for counting, and it's working if i give the static value but if i have a php string in it it gives only zeros.
<?php $r="June 7, 2087 15:03:25"; ?>
<script type="text/javascript">
$(function() {
var endDate = "<?php echo $r;?>";
$('.countdown.simple').countdown({ date: endDate });
});
</script>
you can check the code right here: http://jsbin.com/EboVeCO/1/edit , if you comment the $r and put the date exactly in the JS like it is, it will work, else is not working :(
What's the matter? why isn't it working?
UPDATE:
<?php foreach ($row as $r){
$rr = $r->release_date;
$rrr = date("F d, Y H:i:s", strtotime($rr));
<script type="text/javascript">
$(function() {
var endDate = "<? echo $rrr; ?>";
$('.countdown.simple').countdown({ date: endDate });
});
</script>
echo ' <div class="countdown simple"></div>';
}
THIS wher $row comes from:
public function get_things() {
$q = $this->db->query("SELECT * from s_data");
if($q->num_rows() > 0){
foreach($q->result() as $row){
$data[] = $row;
}
return $data;
}
}
Salut!