Convert String to Date : Casting « Data Type « PHP






Convert String to Date


<HTML>
<BODY>
<FORM METHOD="POST" ACTION="CallMe.php">
    <TABLE>
    
    <TR>
    Date:<BR>
    <TD><INPUT TYPE="TEXT" NAME="DATE" VALUE="<?php echo $DATE ?>"></TD>
    </TR>
    
    <TR>
    <TD ALIGN="CENTER">+</TD>
    </TR>
    
    <TR>
    <TD><INPUT TYPE="TEXT" NAME="OFFSET" VALUE="<?php echo $OFFSET ?>"></TD>
    </TR>
    
    <TR>
    <TD ALIGN="CENTER"><INPUT TYPE="SUBMIT" VALUE="="></TD>
    </TR>
    
    <TR>
    <TD><INPUT TYPE="TEXT" NAME="RESULT" 
      VALUE="<?php echo date("M j, Y",(strtotime($DATE)+60*60*24*($OFFSET))) ?>" disabled></TD>
    </TR>
    
    </TABLE>
</FORM>
</BODY>
</HTML>


           
       








Related examples in the same category

1.Casting a variable
2.Casting the return value
3.Change the data type
4.Changing Type by Casting
5.Converting to in parentheses before our variable name
6.Maintaining the integrity of the data and outputting the end result.
7.Force to change the data type by adding (int), (integer), (float), (double), or (real) in front of the variable
8.When the first expression is a string, the type of the variable will depend on the second expression.
9.convert to float
10.Typecasting
11.Casting a Variable
12.Type conversion: Approach 2
13.Type conversion: Approach 1
14.Type conversion: approach 3
15.Type conversions