Datetime value to string in PHP

Buy 1 Month, Get 2 Months Free. Coupon: 2MOFREE

This one escapes me everytime I need which results to much googling. The function is to convert SQL datetime value to human-readable format.


/* 
*   Converts the likes of '2010-08-01 14:57:15' to 'August 1, 2010, 2:57 pm' 
*/  
$datetime_value ="2010-08-01 14:57:15";
echo date(  "F j, Y, g:i a", strtotime( $datetime_value ) );  

Here’s another example which you will see on some of my templates.

<?php echo date('Y-m-d', strtotime('next month')); ?>

For more formats, go head to PHP Doc.

Reference:

http://php.net/manual/en/function.date.php

Incoming search terms:

  • date to string php
  • php datetime tostring
  • php date to string
  • datetime to string php
  • datetime tostring php
  • php datetime to string
  • date to string in php
  • php date time value
  • php convert date tostring
  • convert date to string in php

Related posts:

  1. Trim String in C++
  2. String Replace in C++

Speak Your Mind

*