Reputation: 8836
I have this jQuery script but instead of getting the time from my computer, how can I get the time on page arrival using the server's time using PHP? No counting or changing in time is needed.
$(function () {
var now = new Date();
$('#date').scroller({
preset: 'datetime',
minDate: new Date(now.getFullYear(), now.getMonth(), now.getDate()),
theme: 'android-ics',
display: 'inline',
mode: 'scroller',
dateOrder: 'ddM',
dateFormat: 'yy-mm-dd',
timeFormat: 'HH:ii:ss',
timeWheels: 'HHii',
stepMinute: 10,
rows: 3
}).scroller('setDate', now, true);
});
Upvotes: 1
Views: 185
Reputation: 71384
Just dynamically insert the time value from PHP into the output javascript.
var serverTime = <?php echo time(); ?>
Obviously you can format the time however you want, this example just unix timestamp.
Then use in you jQuery like this:
$('#date').scroller({
preset: 'datetime',
minDate: serverTime,
theme: 'android-ics',
display: 'inline',
mode: 'scroller',
dateOrder: 'ddM',
dateFormat: 'yy-mm-dd',
timeFormat: 'HH:ii:ss',
timeWheels: 'HHii',
stepMinute: 10,
rows: 3
}).scroller('setDate', now, true);
Upvotes: 1
Reputation: 18891
Assuming the jQuery is inline in your PHP page, you can replace the new Date(...
with <?php echo date(Y:m:d); ?>
You could also insert a function for an ajax request to get the time from your server.
Upvotes: 0