phpeveryday.com

The best tutorial of php, php framework, php strategies, object oriented oriented,


String: Reformating Mysql Datetime to Your Local Date Format

Tag: string, date, mysql   Category: PHP Basic
post: 03 Feb 2008 read: 345


PHP String Tips: We talk about substr at this post. We can expand substr() function like for reformating datetime. Genuine format from datitime is "yyyy-mm-dd hh:ii:ss". But your needed is "dd/mm/yyyy hh:ii:ss". You can use substr for this problem.

We can create function like this:


function reformat_DateTime ($string)
{
$yyyy = substr($string, 0,4);
$month = substr($string, 5,2);
$dd = substr($string, 8,2);
$hh = substr($string, 11,2);
$mm = substr($string, 14,2);
$ss = substr($string, 17,2);
$dtime = "$dd/$month/$yyyy $hh:$mm:$ss";
return $dtime;
}



| Give Your Opinion | Recommend
Share and Bookmark to: These icons link to social bookmarking sites where readers can share and discover new web pages.
digg del.icio.us technorati Ma.gnolia BlinkList

Recommended articles by other readers:
Web Services: How PHP Kiss VB.NET? (Part 1)
Chart: How to Build Cool Animation Real Time Chart
Joomla: Fast Road to Understand Component Programming
Email: Send Attachement Mail
mod_rewrite - Part 1: create your "fantasy" URL

What do You Think?
Your Name *:
Email *:
(Will not be published)
Website/URL:
Your Comment *:
* Required


615
posting