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

 

Link to comment
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.