Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

dates 2

Status
Not open for further replies.

manicleek

Technical User
Jun 16, 2004
143
GB
Can anyone tell me how I can change a date entered as day, month, year into a unix datestamp and vice versa?

and also how can I view the unix datestamp for the current date?
 
for current date use
Code:
  echo strtotime("now");

for the first question use strtotime aswell
Code:
  $timestamp = strtotime ($human_readable_date);

the human readable date must be in one of the gnu input formats. if it is not then you will need to do some string manipulation or redesign the data capture.
 
I will be entering the date into a form with three text boxes, day, month, year

how would that be turned into a datestamp if say the variables were $day, $month, $year?
 
,code]
$timestamp=strtotime($year."-".$month."-".$day);
[/code]
 
If I have have used the above

Code:
$timestamp=strtotime($year."-".$month."-".$day);

To enter a timestamp into a db, how do I reverse the process to output the timestamp as a readable date?
 
date("d/m/Y",strtotime($rowfoundnews['NEWS_DATE']))

where $rowfoundnews['NEWS_DATE'] is your db field
 
Status
Not open for further replies.

Similar threads

Replies
3
Views
302
Replies
12
Views
335
Replies
2
Views
117
Replies
5
Views
92

Part and Inventory Search

Sponsor

Back
Top