0

C: Printing Current System Time

Posted by Joys of Programming on March 19, 2010 in C/C++

There are multiple functions using which you can get the current system time in seconds like gettimeofday().But usage of clock_gettime() is recommended. clock_gettime() returns the number of seconds and nano seconds since the Epoch (January 1, 1970). It’s syntax is int clock_gettime(clockid_t clk_id, struct timespec *tp); where clk_id can take values like CLOCK_REALTIME (which we [...]

Tags: , , , ,

 
0

How to set System Time using NTP?

Posted by Joys of Programming on February 9, 2010 in Linux, Ubuntu

NTP is helpful to synchronize system time of computer over a network. This is very useful if you have multiple computers and you require all the computers to have uniform time. You can start the NTP server in one of the machines and synchronize the time across all the machines using this server. This is [...]

Tags: , , , , ,

 
0

How to display Unix Time in PHP?

Posted by Joys of Programming on December 1, 2009 in PHP

PHP provides the function time() which returns the time passed since January 1,1970. To display the unix time, also called the epoch time <?php $seconds = time(); echo $seconds," seconds" ?> The output will be the number of seconds 1259673210 seconds

Tags: ,

 
0

How to display the time in human readable format in JavaScript?

Posted by Joys of Programming on November 30, 2009 in JavaScript

Date givesmany functions like getTime(), Date() to display the time. Date() returns an object which displays the time in the UTC format. But to display in a format of your choice <head> <title>Time in JavaScript</title> </head> <body> <script type="text/javascript"> <!– var time = new Date(); var year = time.getFullYear(); var month = time.getMonth()+1; var date1 [...]

Tags: , , ,

 
0

How to display the UTC in JavaScript?

Posted by Joys of Programming on November 30, 2009 in JavaScript

The following program will display the current time in UTC. But this program will display it in the default format. <title>Time in UTC</title> <script type="text/javascript"> <!– var time = new Date(); document.write("Time: "+  time ); –> </script> The time will be displayed according to your current time zone

Tags: , , , , ,

 
0

How to Print the Current Time in Human Readable Format in Java?

Posted by Joys of Programming on November 30, 2009 in Java

currentTimeMillis and nanoTime give the current System time in milliseconds and nano seconds. But this is not understood by humans, since the value returned by these functions is the amount of time passed since January 1,1970 To be able to display the time in human readable format, we make use of the java.util.Calendar. Calendar.getInstance() gives [...]

Tags: , ,

 
0

How to find the Greenwich Mean time in Perl?

Posted by Joys of Programming on November 23, 2009 in Perl

Using localtime, you can find the local time. But to find the greenwich mean time also known as GMT, you must make use of the function gmt.

Tags: , , ,

Pages: 1 2 Next

Copyright © 2009-2010 Joys of Programming All rights reserved.
Desk Mess Mirrored v1.7.2 theme from BuyNowShop.com.