Jump to content

[SOLVED] convert date in php


simon551

Recommended Posts

is there a way to change the format of a date that is submitted through an html form?

 

example: I have a form with a date field that accepts a standard U.S. date format of (%m/%d/%Y) but then when this:

($_POST['fdate'], "date")

 

occurs I'd like it to take a date value of (%Y-%m-%d) so that the server will handle it.

 

Thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/56413-solved-convert-date-in-php/
Share on other sites

Insert the dates as a timestamp into an INT column/field.

 

<?php

$mydate = 'January 15, 2005'; //Assuming that is the date submitted in $_POST['fdate'] or whatever
$formatit = strtotime($mydate);

?>

 

When you query for dates later..you can format easily for display....in any format you want using the date() function.

 

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.