Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                function makeFriendlyDates(arr) {
  //array to return 數組返回
  var dateArray = [];
  //split array into year , month and day將數組拆分成年,月,日
  var date1= arr[0].split("-");
  var date2= arr[1].split("-");
  //turn strings into nums for month將字符串變成月數
  date1[1] = Number(date1[1])-1;
  date2[1] = Number(date2[1])-1;
  date1[2] = Number(date1[2]);
  date2[2] = Number(date2[2]);
  date1[0] = Number(date1[0]);
  date2[0] = Number(date2[0]);
  //store name of months商店名稱月份
  var monthNames= ['January','February','March','April','May','June','July','August','September','October','November','December'];
  //Are the two dates the same
  if((date1[0]===date2[0]) && (date1[1]===date2[1]) && (date1[2]===date2[2])){
    dateArray.push(monthNames[date1[1]] + " " + dayChange(date1[2]) + ", " +date1[0]);
    return dateArray;
  }
  //Are the two dates not in the same month but in the same year這兩個日期不是在同一個月,而是在同一年
  else if(date2[1] - date1[1]>=1 && (date2[0] - date1[0] === 0)){
    dateArray.push(monthNames[date1[1]] + " " + dayChange(date1[2]) + ", " + date1[0]);
    dateArray.push(monthNames[date2[1]] + " " + dayChange(date2[2]));
    return dateArray;
  }
  //some month ,same day ,but different years幾個月,同一天,但不同年
  else if((date1[1] === date2[1]) && date2[2] === date1[2] && (date2[0] - date1[0]>=1)){
    dateArray.push(monthNames[date1[1]] + " " + dayChange(date1[2]) + ", " + date1[0]);
    dateArray.push(monthNames[date2[1]] + " " + dayChange(date2[2]) + ", " + date2[0]);
    return dateArray;
  }
  //if same month but different years 如果同一個月但不同的年份
  else if((date1[1] === date2[1]) && date2[0] - date1[0]>=1){
    dateArray.push(monthNames[date1[1]] + " " + dayChange(date1[2]) +", " + date1[0]);
    dateArray.push(monthNames[date2[1]] + " " + dayChange(date2[2]));
    return dateArray;     
  }
  //Are the two dates in the same month這兩個日期是在同一個月
  else if(date1[1] === date2[1]){
    dateArray.push(monthNames[date1[1]] + " " + dayChange(date1[2]));
    dateArray.push(dayChange(date2[2]));
    return dateArray;
    
  }else if(date2[0] - date1[0]>1){
    dateArray.push(monthNames[date1[1]] + " " + dayChange(date1[2]) +", " + date1[0]);
    dateArray.push(monthNames[date2[1]] + " " + dayChange(date2[2]) +", " + date2[0]);
    return dateArray;
  }else{
    dateArray.push(monthNames[date1[1]] + " " + dayChange(date1[2]));
    dateArray.push(monthNames[date2[1]] + " " + dayChange(date2[2]));
    return dateArray;
  }
  
  function dayChange(day){
    if(day === 1){
      return day + "st";
    }else if(day === 3){
      return day + "rd";
    }else {
      return day +"th";
    }
  }
}

makeFriendlyDates(['2016-12-01', '2017-02-03']);

              
            
!
999px

Console