tags:

views:

253

answers:

2

Hello,

I was wondering if there is a way, using PHP, to change this date format: 01.08.86 (January 8, 1986) to this format: 1.8.86.

+2  A: 
<?php

$date = "01.08.86";
$unix = strtotime($date);
echo date('n.j.y', $unix);
Sean Fisher
All I really needed was n.j.y Thanks alot Sean!
j-man86
A: 

How about a regex based solution:

$str = '01.08.86';
$a = array('/^0(\d+)/','/\.0(\d+)/');
$b = array('\1','.\1');
$str = preg_replace($a,$b,$str);

// $str is now '1.8.86'
codaddict