Welcome to my Blog

I am Nelson Desai. I complete computer engineering.

This is my personal blog. Here I share some post, which can helpful for me, my friends and you.

Some post may be illegal to share like some crack and keys. but, i think.. which things put online then it's not be secure any more whatever company try.

So, I requested you pls download and use it at your risk. and don't upload it again online.

Thank You for peeping my blog.. Have a Good Day!

Showing posts with label Date Format. Show all posts
Showing posts with label Date Format. Show all posts

Get the different date format in JavaScript





Hi,  
This is simple code but, i got it after so much time..


var d = new Date();
// Get today date in this format  Fri Jun 29 2012 10:57:53 GMT+0530 (IST). 


var curr_date = d.getDate();
// Get the only date from today date.


var curr_month = d.getMonth();
// Get the only month from today date.


curr_month++;
// Increase month by 1. becz, u got less one. 


var curr_year = d.getFullYear();
// Get the only year from today date.


// You can get also time, second, minute like this. 
var second =d.getSeconds();
var minutes = d.getMinutes();
var hour = d.getHours();
var milliSeconds = d.getMilliseconds();
// And also join it in date. 


// Now join it in any format. 
var today = curr_year + "-" + curr_month + "-" + curr_date;
// like this return 2012-5-12


var today = curr_year + "." + curr_month + "." + curr_date;
// like this return 2012.5.12


var today =  curr_month + "/" + curr_year + "/" + curr_date;
// like this return 5/2012/12

--
Thank You
Nelson Desai

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by NDR Group | Bloggerized by Er. Nelson Desai | Love U My Friends