javascript - How to extract month, day, year, hour in Unix Timestamp? -
in database insert date , time converted timestamp using strtotime, "1444600800" , have time duration service converted same process, "1443740700", using https://github.com/almasaeed2010/adminlte, its' http://fullcalendar.io/, in calendar events, coded event:
events: [ { title: 'all day event', start: new date(y, m, 1), end: new date(y, m, d, 13, 30), backgroundcolor: "#f56954", //red bordercolor: "#f56954" //red } ]
i coded don't succeed:
events: [ <?php $event_query = mysql_query("select *,time_format (`appoint_date`, '%h:%i') appointment inner join service,user appointment.user_id = user.user_id , service.service_id = appointment.service_id")or die(mysql_error()); while($event_row = mysql_fetch_array($event_query)){ ?> { title : '<?php echo $event_row['firstname']; ?> ', start : <?php echo $event_row['appoint_date']; ?>, end : <?php echo $event_row['duration']; ?>, allday: false, backgroundcolor: "#3c8dbc", //primary (light-blue) bordercolor: "#3c8dbc" //primary (light-blue) }, <?php } ?> ]
i thinking of extracting date, month, hour in timestamp , can add hour value of timestamp service duration date , time timestamp , code sample. formula :
`$nextweek = time() + (7 * 24 * 60 * 60); // 7 days; 24 hours; 60 mins; 60 secs echo 'now: '. date('y-m-d') ."\n"; echo 'next week: '. date('y-m-d', $nextweek) ."\n"; // or using strtotime(): echo 'next week: '. date('y-m-d', strtotime('+1 week')) ."\n";`
what do?
start: new date(<?=$event_row['appoint_date']?>000)
note need multiply 1000 (in above, add 3 zeroes) because timestamps in js in milliseconds, whereas in php they're in seconds.
Comments
Post a Comment