Skip to content

Commit 47475d7

Browse files
committed
Update date handling doc
1 parent ba07e3b commit 47475d7

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

doc/api.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9369,10 +9369,19 @@ are not supported.
93699369
Note that JavaScript Date has millisecond precision therefore
93709370
timestamps will lose any sub-millisecond fractional part when fetched.
93719371

9372-
To make applications more portable, it is recommended to always set
9373-
the session time zone to a pre-determined value, such as UTC. This
9374-
can be done by setting the environment variable [`ORA_SDTZ`][42]
9375-
before starting Node.js, for example:
9372+
To make applications more portable, it is recommended to always set the session
9373+
time zone to a pre-determined value, such as UTC. The session timezone should
9374+
generally match the client system timezone, for example the `TZ` environment
9375+
variable or the Windows timezone region.
9376+
9377+
You can find the current session timezone with:
9378+
9379+
```sql
9380+
SELECT sessiontimezone FROM DUAL;
9381+
```
9382+
9383+
You can set the environment variable [`ORA_SDTZ`][42] before starting Node.js,
9384+
for example:
93769385

93779386
```
93789387
$ export ORA_SDTZ='UTC'
@@ -9413,8 +9422,17 @@ BEGIN
94139422
END;
94149423
```
94159424

9416-
See [Working with Dates Using the Node.js Driver][43] for more
9417-
discussion of date handling.
9425+
A query that returns the node-oracledb client-side date and timestamp is:
9426+
9427+
```sql
9428+
oracledb.fetchAsString = [oracledb.DATE];
9429+
result = await connection.execute(`SELECT current_date, current_timestamp FROM DUAL`);
9430+
console.log(result);
9431+
```
9432+
9433+
For more information on time zones, see Oracle Support's [Timestamps & time
9434+
zones - Frequently Asked Questions, Doc ID 340512.1][165]. Also see [Working
9435+
with Dates Using the Node.js Driver][43].
94189436

94199437
##### <a name="fetchasstringhandling"></a> 15.1.6.4 Fetching Numbers and Dates as String
94209438

@@ -14543,3 +14561,4 @@ can be asked at [AskTom][158].
1454314561
[162]: https://www.oracle.com//cloud/free/
1454414562
[163]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=GUID-C672E92D-CE32-4759-9931-92D7960850F7
1454514563
[164]: https://www.oracle.com/pls/topic/lookup?ctx=dblatest&id=SHARD
14564+
[165]: https://support.oracle.com/epmos/faces/DocumentDisplay?id=340512.1

0 commit comments

Comments
 (0)