2011-09-28 60 views
1

我想將當前時間/日期到一個隱藏的文本字段的格式十九時19分09秒2011年9月27日將當前時間日期在隱藏字段

<input type="hidden" name="current_date" value="" readonly="readonly"> 

謝謝

+2

不,你不知道。你想要一個時間戳。 –

+0

你想用php或javascript做這個嗎? –

+0

喜歡PHP,但可以與JS .. – user718359

回答

2
<input type="hidden" name="current_date" value="<?php echo date('H:i:s M d, Y'); ?>" readonly="readonly"> 

但是你應該知道的是,用戶可以方便地改變值。

編輯: 使用date_default_timezone_set設置時區。

澳大利亞的時區在此列出:http://www.php.net/manual/en/timezones.australia.php

+0

剛剛測試過,並且提出了2011年9月9日20:29:59? – user718359

+0

這是基於用戶的時間/日期嗎?或某處中央? – user718359

+0

@ user718359對不起,已編輯。 – xdazz

2

http://php.net/manual/en/function.date.php

<?php 
// Assuming today is March 10th, 2001, 5:16:18 pm, and that we are in the 
// Mountain Standard Time (MST) Time Zone 

$today = date("F j, Y, g:i a");     // March 10, 2001, 5:16 pm 
$today = date("m.d.y");       // 03.10.01 
$today = date("j, n, Y");      // 10, 3, 2001 
$today = date("Ymd");       // 20010310 
$today = date('h-i-s, j-m-y, it is w Day');  // 05-16-18, 10-03-01, 1631 1618 6 Satpm01 
$today = date('\i\t \i\s \t\h\e jS \d\a\y.'); // it is the 10th day. 
$today = date("D M j G:i:s T Y");    // Sat Mar 10 17:16:18 MST 2001 
$today = date('H:m:s \m \i\s\ \m\o\n\t\h');  // 17:03:18 m is month 
$today = date("H:i:s");       // 17:16:18 
?> 



<input type="hidden" name="current_date" value="<?php echo $today?>" readonly="readonly"> 
相關問題