Sundas Subhani
Sundas Subhani

Reputation: 23

PHP. How to assign current date and time to an input field

How to assign default value current time stamp to an input field.

Then I want to insert into db as hidden.

How can I assign a default value (current taimestamp)?

<input name="status" id="status" type="hidden" 
value="<?php echo CURRENT_TIMESTAMP ?>"/>

Upvotes: 0

Views: 5068

Answers (3)

Vimalnath
Vimalnath

Reputation: 6463

You could do it in the backend, just by using a default value to the table column.

UPDATE <table_name> SET <column_name> = NOW();

Upvotes: 0

Amit Horakeri
Amit Horakeri

Reputation: 745

Use value= <?php echo date('Y-m-d H:i:s'); ?>

Set the date format as per your need.

Upvotes: 3

mfo
mfo

Reputation: 152

<input type="hidden" name="tstamp" value="<?php echo time(); ?>" />

Upvotes: 2

Related Questions