Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Date in Dutch

  1. #1
    New to the CF scene
    Join Date
    Nov 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date in Dutch

    Hi there,

    I need to replace the following code, with something in which I can localize the date (months), e.g. 1 okt (instead of oct).

    Can someone please help me? I've tried a lot of different 'solutions' but my js knowlegde is very limited so I'm kind of looking for a copy-paste solution.

    Code:
    // Give the tweet a nice timestamp
    var formatTime = function(pastTime) {
    	 /* Credits to: Zemanta */
    	 var origStamp = Date.parse(pastTime);
    	 var curDate = new Date();
    	 var currentStamp = curDate.getTime();
    	
    	 var difference = parseInt((currentStamp - origStamp)/1000);
    	
    	 if(difference < 0) return false;
    	 if(difference <= 60)           return "seconden geleden";
    	 if(difference < 3600)          return parseInt(difference/60)+" minuten geleden";
    	 if(difference <= 1.5*3600)     return "1 uur geleden";
    	 if(difference < 23.5*3600)     return Math.round(difference/3600)+" uren geleden";
    	 if(difference < 1.5*24*3600)   return "1 dag geleden";
    	
    	 var dateArr = pastTime.split(' ');
    	 return dateArr[4].replace(/\:\d+$/,'')+' '+dateArr[2]+' '+dateArr[1]+(dateArr[3]!=curDate.getFullYear()?' '+dateArr[3]:'');
    };
    Last edited by maarten64; 11-01-2012 at 01:11 PM.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,239
    Thanks
    203
    Thanked 2,554 Times in 2,532 Posts
    Code:
    var dateArr = pastTime.split(' ');
    var x = dateArr[0];
    var emonth = ['January','February','March','April','May','June','July','August','September','October','November','December'];
    var dmonth = ["januari", "februari", "maart", "april", "mei", "juni", "juli", "augustus","september", "oktober","november","december"];
    for(var i = 0; i<emonth.length; i++) {
    if (x == emonth[i]) {x = dmonth[i]}
    dateArr[0] = x;
    }
    alert (dateArr[0]); // for testing
    
    var displaydate = dateArr[1] + " " + dateArr[0] + " " + dateArr[2];
    alert (displaydate);
    He could have done one of three things - he didn't do either. Commentator ITV4
    Last edited by Philip M; 11-01-2012 at 01:43 PM.

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.


  •  

    Posting Permissions

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