My favorites
▼
|
Sign in
lineadecodigo
Web Code Samples in spanish
Project Home
Downloads
Wiki
Issues
Source
Checkout
Browse
Changes
Source path:
svn
/
trunk
/
lineadecodigo_web
/
WebContent
/
scripting
/
javascript
/
basicos
/
convertir-segundos-a-formato-hora.html
r480
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<!DOCTYPE html>
<html>
<head>
<meta charset="ISO-8859-1">
<title>Convertir segundos a formato hora en Javascript</title>
</head>
<body>
<h1>Convertir segundos a formato hora en Javascript</h1>
<script>
segundos = 61;
//segundos = 82800; 23h
//segundos = 86400; 24h
var d=new Date(segundos*1000);
// Ajuste de las 23 horas
var hora = (d.getHours()==0)?23:d.getHours()-1;
var hora = (hora<9)?"0"+hora:hora;
var minuto = (d.getMinutes()<9)?"0"+d.getMinutes():d.getMinutes();
var segundo = (d.getSeconds()<9)?"0"+d.getSeconds():d.getSeconds();
document.write(hora+":"+minuto+":"+segundo);
</script>
<br/><br/>
<hr>
Artículo disponible en: <a href="http://lineadecodigo.com/javascript/convertir-segundos-en-formato-hora-con-javascript/">http://lineadecodigo.com/javascript/convertir-segundos-en-formato-hora-con-javascript/</a><br/>
<a href="http://lineadecodigo.com" title="Linea de Codigo">lineadecodigo.com</a>
</body>
</html>
Show details
Hide details
Change log
r419
by vcuervo on Jan 22, 2012
Diff
Convertir segundos a formato hora con javascript
Go to:
...tir-segundos-a-formato-hora.html
Project members,
sign in
to write a code review
Older revisions
All revisions of this file
File info
Size: 971 bytes, 33 lines
View raw file
Powered by
Google Project Hosting