SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist
    Join Date
    Apr 2003
    Location
    lisboa
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    doubt with Date.toLocaleString()

    i know it returns complete date in my locale, but i wonder if there is something i can do (any other method, for example) so that it does not display hours, min and secs (without using string manipulation)

    TiA

    note: i could allways use a function like:
    HTML Code:
    function dateWithoutHHmmss(data) {
      return data.substring(0, (data.indexOf(":") - 2));
    }

  2. #2
    Programming Since 1978 silver trophybronze trophy felgall's Avatar
    Join Date
    Sep 2005
    Location
    Sydney, NSW, Australia
    Posts
    16,789
    Mentioned
    25 Post(s)
    Tagged
    1 Thread(s)
    The format that returns the date/time in depends on the locale settings on each individual computer. If you just want the date then then you'd be better off creating your own custom method for just retrieving that portion of the content.
    Stephen J Chapman

    javascriptexample.net, Book Reviews, follow me on Twitter
    HTML Help, CSS Help, JavaScript Help, PHP/mySQL Help, blog
    <input name="html5" type="text" required pattern="^$">

  3. #3
    SitePoint Guru
    Join Date
    Apr 2006
    Posts
    802
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use the Date method toDateString() to just return
    a string with the day,month, and year for the Date object

    eg:
    var D=new Date()
    D.toDateString() returns values like this:
    Sat Dec 16 2006

  4. #4
    SitePoint Evangelist
    Join Date
    Apr 2003
    Location
    lisboa
    Posts
    423
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes, but in that case i lose my locale presentation


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
  •