Jump to content

noob time question


AV1611

Recommended Posts

I can't seem to think straight today.

 

I need to do two things:

 

convert a unix timestamp to human readable:

 

for example, if I have

UNIX time 1201976015

I want it do output  02/02/2008 6:13pm GMT.

 

I can write the script, I just can fire out the function

 

Second:

 

For a given day/month/year, what's the function to output the unix time for +7 days?  Thanks.

 

 

Link to comment
https://forums.phpfreaks.com/topic/89098-noob-time-question/
Share on other sites

For your first question

<?php

//Unix Timestamp
$time = time();

//Convert
$date = date("Y-m-d g:i", $time);

echo $date;

?>

 

And for your second:

<?php

//Unix Timestamp
$time = time();

//Convert and add 7 days
$date = date("Y-m-d g:i", strtotime("$date + 7 DAY"));

echo $date;

?>

Link to comment
https://forums.phpfreaks.com/topic/89098-noob-time-question/#findComment-456333
Share on other sites

See any problem here?

 

<?php

$ut= strtotime("+1 week");

echo $ut; //gives me the unix time of 1 week from this second of time

echo "<br />";

$date=getdate($ut);

echo $date['month'].' '.$date['mday'].' '.$date['year'];//gives me the date of the above timestamp (I do not care about time)

?>

Link to comment
https://forums.phpfreaks.com/topic/89098-noob-time-question/#findComment-456334
Share on other sites

I am really asking two different questions, but it seems to be answered here.

 

The system I am working with uses unix time, but I have to create a form that uses a point of time in the future, so I need to use human dates in the form but unix time in the output to a .csv file.

 

Thanks for the help.

 

Link to comment
https://forums.phpfreaks.com/topic/89098-noob-time-question/#findComment-456504
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.