how to print 1965-05-09

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • shamei

    #1

    how to print 1965-05-09

    hi there,

    can anyone there teach me how to solve this?

    my table - date field value return 1965-06-20, i want to display this
    value in d-m-Y format.

    how to print? now i only get it print as 01/01/1970 if the year<1970.

    i know there is an adodb_date function. but then how can i convert
    this value to time format as i also cannot use the strtotime function?
    strtotime also return as -1. which also error.

    help..

    thank you

  • Michael Fesser

    #2
    Re: how to print 1965-05-09

    .oO(shamei)
    [color=blue]
    >can anyone there teach me how to solve this?
    >
    >my table - date field value return 1965-06-20, i want to display this
    >value in d-m-Y format.[/color]

    Why not let the database return the date in the format you like?
    [color=blue]
    >how to print? now i only get it print as 01/01/1970 if the year<1970.[/color]

    That's the starting point of Unix timestamps. Some systems also allow
    negative timestamps for dates <1970, but not all.

    Micha

    Comment

    • Chung Leong

      #3
      Re: how to print 1965-05-09

      "shamei" <seowli@gmail.c om> wrote in message
      news:1107182061 .488885.54340@c 13g2000cwb.goog legroups.com...[color=blue]
      > hi there,
      >
      > can anyone there teach me how to solve this?
      >
      > my table - date field value return 1965-06-20, i want to display this
      > value in d-m-Y format.
      >
      > how to print? now i only get it print as 01/01/1970 if the year<1970.
      >
      > i know there is an adodb_date function. but then how can i convert
      > this value to time format as i also cannot use the strtotime function?
      > strtotime also return as -1. which also error.
      >
      > help..
      >
      > thank you
      >[/color]

      There's good old sscanf() you can use:

      sscanf($date, "%4d-%2d-%d", &$year, &$mon, &$day);

      echo "$day/$mon/$year";


      Comment

      • Admin TreeNet

        #4
        Re: how to print 1965-05-09

        In article <1107182061.488 885.54340@c13g2 000cwb.googlegr oups.com>,
        seowli@gmail.co m says...[color=blue]
        > hi there,
        >
        > can anyone there teach me how to solve this?
        >
        > my table - date field value return 1965-06-20, i want to display this
        > value in d-m-Y format.
        >
        > how to print? now i only get it print as 01/01/1970 if the year<1970.
        >
        > i know there is an adodb_date function. but then how can i convert
        > this value to time format as i also cannot use the strtotime function?
        > strtotime also return as -1. which also error.
        >
        > help..
        >
        > thank you
        >[/color]

        SQL has the solution.
        Syntax may differ depending on the backend Database (Access over ODBC?)
        but what you want is something like:

        SELECT DATE_FORMAT('dd-mm-YYYY', DateField) AS 'Date' FROM items;

        Lookup the DATE_FORMAT for exact values available in the format field.

        Note of advice:
        Avoid confusing dates such as 02-01-01
        Jan 1st? Feb 2nd? 2001? or 2002? ... 1902?

        Particularly when producting any sort of information accessed by the
        public, or many people, or used for historic references.

        If you can, leave it in international format or use '01 Jan 2005', etc.

        --
        AJ
        Treehouse Networks abuse@

        Comment

        Working...