LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Converting the date (not timestamp) (https://www.linuxquestions.org/questions/programming-9/converting-the-date-not-timestamp-170325/)

mpgram 04-14-2004 11:22 PM

Converting the date (not timestamp)
 
Ok, here is the problem I am facing.

Using the /etc/shadow file, an account expires 12600. Now, I know that this is the number of days since 01/01/1970 until the account expires.

I am trying to write a php script that takes that number and translates it to the actual date (Jul-1-2004). Does anyone have any ideas? I am completely stumped. Even if its just an algorithim, its better than I can come up with.

Thanks in advance,

Mark

bigredgiant1 04-14-2004 11:37 PM

I didn't quite understand the 12600 days since 1970, and how that is a dynamic date for account deletion, but here you go. You might have to add mktime() to $timestamp to make it dynamic.

Code:

<?php
// Change days into hours, then hours into minutes
// then minutes into seconds
// Thus the # of seconds since 1970
$timestamp = 12600 * 24 * 60 * 60;
echo date("M-j-Y", $timestamp);
?>


mpgram 04-18-2004 03:56 PM

Thanks,

in a round about way, that worked!

Thanks for the help.


All times are GMT -5. The time now is 09:12 AM.