SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    manipulate a date

    I have a date generated in dd/mm/yyyy. I need to compare this to another date which is in the format mm/dd/yyyy to see if the second date comes after the first date. How can I turn the first date into the format dd/mm/yyyy? Some sort of string maipulation needs to happen I guess.
    Thanks.

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Post #17 of a recent thread has a swapDayMonth function that goes as follows:

    Code javascript:
    function swapDayMonth(textDate) {
        var regex = /(\d+)\/(\d+)\/(\d+)(.*)/;
        return textDate.replace(regex, '$2/$1/$3$4');
    }
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2008
    Posts
    43
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just what I was looking for. Cheers


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
  •