IT Community - Software Programming, Web Development and Technical Support

Get GMT date in javascript

This is a discussion on Get GMT date in javascript within the HTML, CSS and Javascript Coding Techniques forums, part of the Web Development category; Hi, Can anyone tell me how to get GMT date in javascript? i can get local system time using Javascript...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Web Development > HTML, CSS and Javascript Coding Techniques

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 02-29-2008, 07:06 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Get GMT date in javascript

Hi,
Can anyone tell me how to get GMT date in javascript? i can get local system time using Javascript
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-08-2008, 01:33 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Get GMT date in javascript

Hi,
I have found one solution for this
HTML Code:
<script language="javscript">
var newDate = getGMTDate();
function getGMTDate()
{	
	var theDate = new Date();
	
	var timezone = parseInt(theDate.getTimezoneOffset()*60*1000);
	newdate = new Date(parseInt(theDate.getTime())+ timezone);
	
		newdate = newdate.getFullYear()+"-"+(newdate.getMonth()+1)+"-"+newdate.getDate()+" "+newdate.getHours()+":"+newdate.getMinutes()+":"+newdate.getSeconds();
		
	
	return newdate;
	
}
</script>
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 03-18-2008, 07:06 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Get GMT date in javascript

Hi,
Can anyone tell me what is daylight saving time?
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 03-18-2008, 11:46 PM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Get GMT date in javascript

Here i have got some information on Daylight saving time

Daylight saving time (DST; also summer time in British English) is the convention of advancing clocks so that afternoons have more daylight and mornings have less. Typically clocks are adjusted forward one hour near the start of spring and are adjusted backward in autumn. Modern DST was first proposed in 1907 by William Willett. Many countries have used it since then; details vary by location and change occasionally.
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 03-18-2008, 11:51 PM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Get GMT date in javascript

if you want to know more on Daylight saving time click here
Daylight saving time - Wikipedia, the free encyclopedia
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 03-29-2008, 12:04 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Get GMT date in javascript

You can use the following equations to calculate when DST starts and ends. The divisions are integer divisions, in which remainders are discarded. "mod" means the remainder when doing integer division, e.g., 20 mod 7 = 6. That is, 20 divided by 7 is 2 and 6/7th (where six is the remainder). With: y = year.
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 03-29-2008, 12:05 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Get GMT date in javascript

Equation For the United States:

Begin DST: Sunday April (2+6*y-y/4) mod 7+1
End DST: Sunday October (31-(y*5/4+1) mod 7)
Valid for years 1900 to 2006, though DST wasn't adopted until the 1950s-1960s. 2007 and after:
Begin DST: Sunday March 14 - (1 + y*5/4) mod 7
End DST: Sunday November 7 - (1 + y*5/4) mod 7;
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 03-29-2008, 12:07 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Get GMT date in javascript

Most of the United States begins Daylight Saving Time at 2:00 a.m. on the second Sunday in March and reverts to standard time on the first Sunday in November. In the U.S., each time zone switches at a different time.

In the European Union, Summer Time begins and ends at 1:00 a.m. Universal Time (Greenwich Mean Time). It begins the last Sunday in March and ends the last Sunday in October. In the EU, all time zones change at the same moment.
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 03-30-2008, 06:24 PM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Get GMT date in javascript

Hi Guys,
How do we compare two dates in javascript?
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 03-31-2008, 08:08 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Get GMT date in javascript

HTML Code:
<Script language=javascript>

dt1=getDateObject("10/13/2008","/");
dt2=getDateObject("01/01/2006","/");

if(dt1>dt2)
	alert("dt1 is greater than dt2")
else
	alert("dt1 is less than dt2")

function getDateObject(dateString,dateSeperator)
{
	//This function return a date object after accepting 
	//a date string ans dateseparator as arguments
	var curValue=dateString;
	var sepChar=dateSeperator;
	var curPos=0;
	var cDate,cMonth,cYear;

	//extract day portion
	curPos=dateString.indexOf(sepChar);
	cDate=dateString.substring(0,curPos);
	
	//extract month portion				
	endPos=dateString.indexOf(sepChar,curPos+1);			cMonth=dateString.substring(curPos+1,endPos);

	//extract year portion				
	curPos=endPos;
	endPos=curPos+5;			
	cYear=curValue.substring(curPos+1,endPos);
	
	//Create Date Object
	dtObject=new Date(cYear,cMonth,cDate);	
	return dtObject;
}
</script>
i think this will help you to compare 2 dates in javascript
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #11 (permalink)  
Old 03-31-2008, 10:38 PM
krishnakumar krishnakumar is offline
D-Web Analyst
 
Join Date: May 2007
Posts: 206
krishnakumar is on a distinguished road
Default Re: Get GMT date in javascript

Hi,

I need to check whether the current year is leap year or not using javascript.
Is there any method to find the leap year like to get TimeZone .

Can anyone help me
__________________
Krishnakumar.S
Beware of Everything -that is un true; stick to the Truth shall succeed slowly but steadily
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 04-01-2008, 07:25 AM
Jeyaseelansarc Jeyaseelansarc is offline
D-Web Genius
 
Join Date: Mar 2007
Location: Chennai
Posts: 1,162
Jeyaseelansarc is on a distinguished road
Send a message via AIM to Jeyaseelansarc
Default Re: Get GMT date in javascript

Hi,
I think it can help you to find Leap Year
HTML Code:
<script language="JavaScript">

function checkleapyear(datea)
{
	datea = parseInt(datea);

	if(datea%4 == 0)
	{
		if(datea%100 != 0)
		{
			return true;
		}
		else
		{
			if(datea%400 == 0)
				return true;
			else
				return false;
		}
	}
return false;
}
//# - Call as
checkleapyear(2000);
__________________
With,
J. Jeyaseelan

Everything Possible
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert a date in milliseconds back to a date string itbarota HTML, CSS and Javascript Coding Techniques 2 03-03-2008 09:03 PM
How can I show the documents last modified date in the format: month, date, year, tim Pvinothkumar HTML, CSS and Javascript Coding Techniques 3 12-28-2007 05:58 AM
How do I format the Last-Modified date with javascript? Pvinothkumar HTML, CSS and Javascript Coding Techniques 1 10-12-2007 11:17 PM
How to find the Starting date of week from a particular date kingmaker C# Programming 1 08-16-2007 11:25 PM
How to convert a date to a globally accepted date format, in DOT NET 2005? Archer C# Programming 1 07-25-2007 03:21 AM


All times are GMT -7. The time now is 11:12 AM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0