Professional Web Applications Themes

date mysql - PHP Development

Hi I have troubles with converting a date value to unixtime! In mysql I have a table named date TYPE "DATE" (2003-09-05) Now I want it to convert to a date() 05-09-2003 in a html page. I've tried many things but only the year is correct? 'This should work but doesn't? $resultset = mysql_query($SQL_statement); while($data = mysql_fetch_array($resultset)) { $ts=$data['date']; $unixtime = mktime(substr($ts,0, 4), substr($ts,5, 6), substr($ts,8, 9)); echo date("j-n-Y", $unixtime); Who can help me please Ruud...

  1. #1

    Default date mysql

    Hi
    I have troubles with converting a date value to unixtime!
    In mysql I have a table named date TYPE "DATE"
    (2003-09-05)
    Now I want it to convert to a date() 05-09-2003 in a html page.

    I've tried many things but only the year is correct?

    'This should work but doesn't?

    $resultset = mysql_query($SQL_statement);
    while($data = mysql_fetch_array($resultset)) {
    $ts=$data['date'];
    $unixtime = mktime(substr($ts,0, 4), substr($ts,5, 6), substr($ts,8, 9));
    echo date("j-n-Y", $unixtime);

    Who can help me please Ruud


    --==Pyrix==-- Guest

  2. #2

    Default Re: date mysql

    he best way to store date and time in a database is by using the unix
    timestamp ( integer 11 pos long) and by recalling use date ("d-m-Y")
    in your case.

    in case of strange date's look on the internet for vlibdate a very nice
    date handeling class.

    john [email]dzjondds.nl[/email]

    --==Pyrix==-- wrote:
    > Hi
    > I have troubles with converting a date value to unixtime!
    > In mysql I have a table named date TYPE "DATE"
    > (2003-09-05)
    > Now I want it to convert to a date() 05-09-2003 in a html page.
    >
    > I've tried many things but only the year is correct?
    >
    > 'This should work but doesn't?
    >
    > $resultset = mysql_query($SQL_statement);
    > while($data = mysql_fetch_array($resultset)) {
    > $ts=$data['date'];
    > $unixtime = mktime(substr($ts,0, 4), substr($ts,5, 6), substr($ts,8, 9));
    > echo date("j-n-Y", $unixtime);
    >
    > Who can help me please Ruud
    >
    >
    dzjon Guest

Similar Threads

  1. Mysql Date Problem
    By Scorpio_Boy in forum Dreamweaver AppDev
    Replies: 3
    Last Post: April 2nd, 01:44 PM
  2. Formatting date from MySql
    By oeyvind toft in forum PHP Development
    Replies: 5
    Last Post: October 20th, 10:50 PM
  3. php-mysql date problem
    By Dominique Javet in forum PHP Development
    Replies: 1
    Last Post: May 4th, 11:31 PM
  4. PHP Date into MySQL
    By Sue Roussie in forum PHP Development
    Replies: 1
    Last Post: February 13th, 10:11 PM
  5. mysql date to timestamp
    By Ben in forum PHP Development
    Replies: 2
    Last Post: December 8th, 05:22 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139