Skip to content

Commit a138407

Browse files
committed
Use JS Date's getFullYear() in first example.
In year 2012, seeing the output of 112 confused me, and would potentially confuse any JS noob. I thought it was some bug in node-postgres. Presumably, JS starts counting time from Jan 1, 1900! Also, according to [1], getYear() is deprecated and one should use getFullYear() instead. [1] http://www.w3schools.com/jsref/jsref_obj_date.asp
1 parent a029e65 commit a138407

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ var conString = "tcp://postgres:1234@localhost/postgres";
2323
pg.connect(conString, function(err, client) {
2424
client.query("SELECT NOW() as when", function(err, result) {
2525
console.log("Row count: %d",result.rows.length); // 1
26-
console.log("Current year: %d", result.rows[0].when.getYear());
26+
console.log("Current year: %d", result.rows[0].when.getFullYear());
2727
});
2828
});
2929
```

0 commit comments

Comments
 (0)