請問如何獲得當前時間?我想用前面的文字顯示當前時間。如何獲得jquery mobile或jquery的當前時間
例子:
我不得不採取在其中我有一個標籤(有當前時間)一個div標籤,我想顯示一些文本前面。怎麼做?
其實我的問題是不同的。我正在解決突破部分的問題。
感謝
請問如何獲得當前時間?我想用前面的文字顯示當前時間。如何獲得jquery mobile或jquery的當前時間
例子:
我不得不採取在其中我有一個標籤(有當前時間)一個div標籤,我想顯示一些文本前面。怎麼做?
其實我的問題是不同的。我正在解決突破部分的問題。
感謝
你的意思是這樣的:
function date() {
var now = new Date(),
now = now.getHours()+':'+now.getMinutes()+':'+now.getSeconds();
$('#time').html(now);
}
你可能做的最好只是用常規的JavaScript的時間: Date對象有一個getTime方法: http://www.w3schools.com/jsref/jsref_gettime.asp
var currentTime = new Date()
var hours = currentTime.getHours()
var minutes = currentTime.getMinutes()
if (minutes < 10)
minutes = "0" + minutes
然後,使用jQuery你可以在你的div顯示它:
$('#divID').prepend('<p>Text before timestamp<p>');
[jQuery的的getTime函數]的
現在我真正的問題是這樣的.. http://stackoverflow.com/questions/17881261/how-to-show-time-in-front-of-web-service-data-in-jquery-mobile/17881466?noredirect = 1#17881466 – Rohit
實際上,我在幾秒鐘後從服務器獲取數據但是它沒有發送任何時間。因此,我需要在我的屏幕上顯示數據的時間。所以我需要在其中創建一個div我有兩個div一個div有當前時間,其他的是數據。我可以。你可以製作任何其他結構嗎? – Rohit
文本不在同一行.. :(這裏是小提琴http://jsfiddle.net/DhneL/ – Rohit
可能重複(:
然後,您可以在前面加上任何文本你前面那個想http://stackoverflow.com/questions/670290/jquery-gettime-function) – Sergio
正文呢?爲了什麼? – svillamayor
請解決這個問題 http://stackoverflow.com/questions/17881261/how-to-show-time-in-front-of-web-service-data-in-jquery-mobile/17881466?noredirect=1# 17881466 – Rohit