Jump to content


mysql, date


9 replies to this topic

#1 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 27 May 2009 - 07:20 PM

when you the table row type is DATE, and you use CURDATE() to insert the date, the format is YYYY-MM-DD, is there a way in PHP to rotate the format to MM-DD-YYYY but still inserting it the way it's sapose to in the DB just changing the format on the page it's being displayed from?

#2 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 27 May 2009 - 07:33 PM

I figured it out.... For all of you who are wondering as well here is my code:

before: YYYY-MM-DD

<?php

$date = list($year, $month, $day)=split('[/.-]', $row['date']); // [/.-] searches for the symbol(s) / . or -
$date = "$month-$day-$year";

echo $date;

?>

after: MM-DD-YYYY

enjoy!

#3 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 27 May 2009 - 09:26 PM

So you know, list() doesn't return anything, so the following line should not have "$date = "
$date = list($year, $month, $day)=split('[/.-]', $row['date']); // [/.-] searches for the symbol(s) / . or -


#4 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 28 May 2009 - 02:36 PM

But it works still doesn't it??? :blink:

Edited by derek.sullivan, 28 May 2009 - 02:37 PM.


#5 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 28 May 2009 - 05:34 PM

Only because PHP is interpreted. If it were a compiled language, something would probably yell at you.

Either way, it is not a practice you should get into.

#6 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 28 May 2009 - 06:40 PM

witchcraft isn't a practice i should get into either :blink:

#7 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 28 May 2009 - 10:05 PM

Ok, congradulations on solving the problem then.

#8 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 29 May 2009 - 11:28 AM

battles are hard to win with hard-headed men :blink: thanks BTW lol

#9 sanitarium

    Young Padawan

  • Members
  • Pip
  • 11 posts

Posted 30 May 2009 - 08:19 AM

you can use onlt timestamp
i think that's more easy

#10 derek.sullivan

    Jedi In Training

  • Members
  • PipPip
  • 341 posts
  • Gender:Male
  • Location:Georgia
  • Interests:preaching, programming, music, friends, outdoors, moves, books

Posted 30 May 2009 - 09:05 AM

Correct, but I want to get acquainted with all mysql fields, rows, querys, etc etc...





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users