Jump to content


Photo

yyyy-mm-dd to dd-mm-yy


  • Please log in to reply
2 replies to this topic

#1 sun14php

sun14php
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 26 June 2006 - 08:03 AM

Q1.how do i display mysql yyyy-mm-dd date into browse as dd-mm-yy format using php or whatever ?
Q2. can set input-mask in html's textbox to accept date as dd-mm-yy ?

#2 hackerkts

hackerkts
  • Members
  • PipPipPip
  • Advanced Member
  • 593 posts
  • LocationSingapore
  • Age:18

Posted 26 June 2006 - 08:43 AM

I'm not very sure what you mean, but this is the date format you wants.

date(d-m-y);

Please refer to [a href=\"http://sg.php.net/date\" target=\"_blank\"]http://sg.php.net/date[/a] for more informations.

Regards,
hackerkts

To be a coder, you must learn how to think and not to give up so easily.


#3 Orio

Orio
  • Staff Alumni
  • Advanced Member
  • 2,491 posts

Posted 26 June 2006 - 09:47 AM

You can use explode()...

<?php
//$date is in yyyy-mm-dd format
$explode=explode("-",$date);
$new_date=$explode[2]."-".$explode[1]."-".$explode[0];
echo $new_date;
?>

Orio.

EDIT-
And if you want to convet yyyy to yy, do this:
<?php
//$date is in yyyy-mm-dd format
$explode=explode("-",$date);
$explode[0]=substr($explode[0], -1, 2);
$new_date=$explode[2]."-".$explode[1]."-".$explode[0];
echo $new_date;
?>

Think you're smarty?

(Gone until 20 to November)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users