FesterWerks

Radio

Timestamp

Source: Timestamp Conversion Utility
<?
function pad_leading_zero($int)
{
    if(
$int 10) {
        
$return['clean']    = $int;
        
$return['dirty']    = "0$int";
    }
    else {
        
$return['clean']    = $int;
        
$return['dirty']    = $int;
    }
    return 
$return;
}
?>
<HTML>
<HEAD>
<STYLE type="text/css">
<!--
BODY {
    font-family: helvetica,arial,sans-sarif;
}
TH {
    background-color:   #CCF;
    font-weight:        bold;
    font-size:          large;
}
TD {
    padding:            3px;
}
TABLE.tstamp {
    background-color:   #99F;
    padding:            20px;
    border:             5px #33C double;
}
HR {
    width:              95%;
    height:             5px;
}
.values {
    color:              #F00;
    letter-spacing:     2px;
}
-->
</STYLE>
</HEAD>
<BODY>
<FORM method=post name=tstamp action="">
<TABLE align=center border=0 class=tstamp>
<TH>UNIX Timestamp Conversion Utility</TH>
<TR>
    <TD colspan=2>
    <?
    
if(!$submit) { $submit "Convert Timestamp"$timestamp time(); }
    switch (
$submit) {
        case 
"Convert Timestamp":
            
$date   date("l F j, Y g:i:s a"$timestamp);
            
$month  date("n",$timestamp);
            
$day    date("j",$timestamp);
            
$year   date("Y",$timestamp);
            
$hour   date("G",$timestamp);
            
$minute date("i",$timestamp);
            
$second date("s",$timestamp);
            
$day_of_week    date("w",$timestamp);
            
$day_of_year    date("z",$timestamp);
            if(
date("L",$timestamp)) { $is_leap "Yes"; } else { $is_leap "No"; }
            print 
"<B>Date:</B> <SPAN class=values>$date</SPAN>";
            print 
"<BR>\n\t<B>Timestamp:</B> <SPAN class=values>$timestamp</SPAN>";
            print 
"<BR>\n\t<B>Leap Year?:</B> <SPAN class=values>$is_leap</SPAN>";
            print 
"<BR>\n\t<B>Day of Week:</B> <SPAN class=values>$day_of_week</SPAN>"
            print 
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            print 
"<B>Day of Year:</B> <SPAN class=values>$day_of_year</SPAN>";
        break;
        case 
"Convert Date":
            
$timestamp mktime($hour,$minute,$second,$month,$day,$year);
            
$date date("l F j, Y g:i:s a"$timestamp);
            
$day_of_week    date("w",$timestamp);
            
$day_of_year    date("z",$timestamp);
            if(
date("L",$timestamp)) { $is_leap "Yes"; } else { $is_leap "No"; }
            print 
"<B>Date:</B> <SPAN class=values>$date</SPAN>";
            print 
"<BR><B>Timestamp:</B> <SPAN class=values>$timestamp</SPAN>";
            print 
"<BR><B>Leap Year?:</B> <SPAN class=values>$is_leap</SPAN>";
            print 
"<BR><B>Day of Week:</B> <SPAN class=values>$day_of_week</SPAN> ";
            print 
"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            print 
"<B>Day of Year:</B> <SPAN class=values>$day_of_year</SPAN>";
        break;
    }
    
?>
        
    <HR>
    </TD>
</TR>
<TR>
    <TD colspan=2>Enter Unix Timestamp to Convert:</TD>
</TR>
<TR>
    <TD>
        <INPUT type="text" name="timestamp" value="<? print $timestamp;?>" size="15" maxlength="15">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <INPUT type="submit" name="submit" value="Convert Timestamp"><HR>
    </TD>
</TR>
<TR>
    <TD>Select Date (mm:dd:yyyy hh:mm:ss) to Convert</TD>
</TR>
<TR>
    <TD>
        <SELECT name=month>
        <?
        
for($i=1$i<13$i++) {
            
$cleaned_up pad_leading_zero($i);
            if(
$i == $month) {$selected " SELECTED";}else{$selected "";}
            print 
"\t\t<OPTION value=".$cleaned_up[clean]."$selected>".$cleaned_up[dirty]."\n";
        }
        
?>
        </SELECT>
        /
        <SELECT name=day>
        <?
        
for($i=1$i<32$i++) {
            
$cleaned_up pad_leading_zero($i);
            if(
$i == $day) {$selected " SELECTED";}else{$selected "";}
            print 
"\t\t<OPTION value=".$cleaned_up[clean]."$selected>".$cleaned_up[dirty]."\n";
        }
        
?>
        </SELECT>
        /
        <SELECT name=year>
        <?
        
for($i=1900$i<2039$i++) {
            if(
$i == $year) {$selected " SELECTED";}else{$selected "";}
            print 
"\t\t<OPTION value=".$i."$selected>".$i."\n";
        }
        
?>
        </SELECT> 
        &nbsp;&nbsp;&nbsp;
        <SELECT name=hour>
        <?
        
for($i=0$i<24$i++) {
            
$cleaned_up pad_leading_zero($i);
            if(
$i == $hour) {$selected " SELECTED";}else{$selected "";}
            print 
"\t\t<OPTION value=".$cleaned_up[clean]."$selected>".$cleaned_up[dirty]."\n";
        }
        
?>
        </SELECT>
        :
        <SELECT name=minute>
        <?
        
for($i=0$i<60$i++) {
            
$cleaned_up pad_leading_zero($i);
            if(
$i == $minute) {$selected " SELECTED";}else{$selected "";}
            print 
"\t\t<OPTION value=".$cleaned_up[clean]."$selected>".$cleaned_up[dirty]."\n";
        }
        
?>
        </SELECT>
        :
        <SELECT name=second>
        <?
        
for($i=0$i<60$i++) {
            
$cleaned_up pad_leading_zero($i);
            if(
$i == $second) {$selected " SELECTED";}else{$selected "";}
            print 
"\t\t<OPTION value=".$cleaned_up[clean]."$selected>".$cleaned_up[dirty]."\n";
        }
        
?>
        </SELECT>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <INPUT type="submit" name="submit" value="Convert Date">
    </TD>
</TR>
</TABLE>
</FORM>
</BODY>
All pages © FesterWerks Page URL http://festerwerks.com/utils/timestamp.php