Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Sascha Manns
Added: Jul 4, 2018 8:40 PM
Views: 4
Tags: date
This snipped returns the current date in form yyyy-mm-dd
  1. var date = new Date();
  2.    
  3. var month = String(date.getMonth() + 1);
  4. var day = String(date.getDate());
  5. var year = String(date.getFullYear());
  6.    
  7. if (month.length < 2)
  8.     month = '0' + month;
  9.        
  10.  if (day.length < 2)
  11.      day = '0' + day;
  12.    
  13. return day + '.' + month + '.' + year; yyyy-mm-dd