Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1ccb75c

Browse files
committed
Add time functions
1 parent e9c9a04 commit 1ccb75c

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

source/topics/script.rst

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ If you have a string value of time and you need to write it in a field with the
236236
DBInsert("mytable", "name,mytime", "John Dow", "timestamp " + $txtime )
237237
238238
239+
Following Simvolio functions work with date and time in SQL format:
240+
241+
- :ref:`BlockTime`
242+
- :ref:`DateTime`
243+
- :ref:`UnixDateTime`
239244

240245

241246
Contract Editor
@@ -571,6 +576,15 @@ Operations with system parameters:
571576
- :ref:`DBUpdateSysParam`
572577

573578

579+
Operations with date and time in SQL format:
580+
581+
.. hlist::
582+
:columns: 3
583+
584+
- :ref:`BlockTime`
585+
- :ref:`DateTime`
586+
- :ref:`UnixDateTime`
587+
574588
Functions for VDE:
575589

576590
- :ref:`HTTPRequest`
@@ -2259,6 +2273,80 @@ Example
22592273
json = JSONToMap(ret)
22602274
22612275
2276+
.. _BlockTime:
2277+
2278+
BlockTime
2279+
---------
2280+
2281+
Returns generation time of a block in SQL format.
2282+
2283+
Use this function instead of the ``NOW()`` function.
2284+
2285+
2286+
Syntax
2287+
""""""
2288+
2289+
.. code-block:: text
2290+
2291+
BlockTime()
2292+
2293+
2294+
Example
2295+
"""""""
2296+
2297+
.. code:: js
2298+
2299+
DBInsert(`mytable`, `created_at`, BlockTime())
2300+
2301+
2302+
2303+
.. _DateTime:
2304+
2305+
DateTime
2306+
--------
2307+
2308+
Converts unixtime to a string in the `YYYY-MM-DD HH\:MI\:SS` format.
2309+
2310+
2311+
Syntax
2312+
""""""
2313+
2314+
.. code-block:: text
2315+
2316+
DateTime(unixtime int) string
2317+
2318+
2319+
Example
2320+
"""""""
2321+
2322+
.. code:: js
2323+
2324+
DateTime(1532325250)
2325+
2326+
2327+
.. _UnixDateTime:
2328+
2329+
UnixDateTime
2330+
------------
2331+
2332+
Converts a string in the `YYYY-MM-DD HH\:MI\:SS` format to unixtime.
2333+
2334+
2335+
Syntax
2336+
""""""
2337+
2338+
.. code-block:: text
2339+
2340+
UnixDateTime(datetime string) int
2341+
2342+
2343+
Example
2344+
"""""""
2345+
2346+
.. code:: js
2347+
2348+
UnixDateTime("2018-07-20 14:23:10")
2349+
22622350
22632351
System Contracts
22642352
================

0 commit comments

Comments
 (0)