Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.