Re: FormatDateTime Revisited



PHP has some great date functions for formatting dates however you
could possibly want. First take a look at www.php.net/date for a list
of formats.

Notice that the second (optional) parameter to the date function is a
timestamp parameter. You must convert your date/time into a unix
timestamp but this can easily be achieved with the strtotime() function
(www.php.net/strtotime).

So basically you would want to do:

echo date("Y-m-d H:i:s", strtotime("December 25, 2005 11:55 PM"));
// this should return 2005-12-25 23:55:00 - this is the format I
usually use when inserting into MySQL

Note that strtotime should be able to take in just about ANY format of
date and time.

.



Relevant Pages

  • Re: MySQL DATETIME and PHP Dates
    ... > Is there an easy way of formatting a MySQL DATETIME field in PHP. ... Check out the strtotime() function: ...
    (comp.lang.php)
  • Re: FormatDateTime Revisited
    ... I have the date and time fields separate at the moment. ... > PHP has some great date functions for formatting dates however you ... > timestamp parameter. ... > timestamp but this can easily be achieved with the strtotime() function ...
    (comp.lang.php)
  • Re: [PHP] New to PHP question
    ... have a question regarding the formatting of text. ... when I use the \n and run the script from the command line it ... From what I am seeing in the responses if I plan on using php for command ... beginning, blah blah blah. ...
    (php.general)
  • Re: CSV to XML file conversion utility made available
    ... I am often asked to provide output from the database in a spreadsheet ... but I wanted more formatting control. ... Open Source PHP module that does CSV file to XLS file output with a ... a PHP program, it should work on any O/S that you can install PHP 4.3 ...
    (comp.databases.pick)
  • Re: Verbose functional languages?
    ... possibility to override in widget definitions; this decouples formatting ... This is how generating HTML looks like (with apologies for the yucky syntax, PHP is what you get if you do web programming, so I don't really have a choice): ... Formatting is looked up in a global array. ... Its operation is mostly based on the $metadata that is finds under the field name, though it's possible to replace some or all of the information by passing in override data. ...
    (comp.lang.functional)