Formatting Timestamp
Hi,
I have 2 columns "START_TIME" and "END_TIME" with the datatype, TIMESTAMP in my table. I want to calculate the difference between 2 timestamps in my table, so I used a simple query:
select (start_time-end_time) from test where name='XYZ';
The above gives the answer in the format:
000000000 00:01:43.000000
I just want the Hours, Mins and the seconds and eliminate all the unnecessary '0'.
How can I do this?
Thanks!
You can use the extract function for such purposes:
SQL> select extract(second from current_timestamp) from dual;
EXTRACT(SECONDFROMCURRENT_TIMESTAMP)
45.97092
SQL> select extract(minute from current_timestamp) from dual;
EXTRACT(MINUTEFROMCURRENT_TIMESTAMP)
3
SQL> select extract(hour from current_timestamp) from dual;
EXTRACT(HOURFROMCURRENT_TIMESTAMP)
14
Similar Messages
-
How to parse WPP format timestamps ?
hi,
Trying to use messageanalyzer for our custom log files. We log the timestamp in the same format as WPP traces do (for legacy tools).
e.g:
06/03/2014-16:10:57.854
How do I indicate in my config that the timestamp is in this format ? As it stands if I set IsTimeStamp=true, analyzer fails to parse the field as a datetime.The format for Timestamp is pretty strict. But you can parse the data using a syntax statement that extracts the date/time from the current string.
In this example, the date is split in two. For your example, you could just parse the same string twice for each part. Then a property, SCCMtsDateTime, sets the IsTimeStamp aspect and takes a Base message as the type. If you derive your
message from that base type, as in the example at the end.
// Base type for all messages
message BaseTimeStamp : LogEntry
string Time;
string Date;
// Syntax creates a type based on an regex expression
// time="17:24:35.005+300" date="07-08-2013"
syntax CustomDateTimeFormat = month:regex{[0-9][0-9]} "-" day:regex{[0-9][0-9]} "-" year:regex{[0-9]+} " " hours:regex{[0-9][0-9]} ":" minutes:regex{[0-9][0-9]} ":" seconds:regex{[0-9][0-9]} "." fract:regex{[0-9]+} "+" tz:regex{[0-9]+}
=> ToDateTime(year + "-" + month + "-" + day + "T" + hours + ":" + minutes + ":" + seconds + "." + fract + "+" + tz);
// Property to return date type given a message of type BaseNetLogon. Aspects for IsTimestamp allow you to replace the timestamp value.
DateTime get SCCMtsDateTime(this BaseTimeStamp msg) with EntryFieldInfo {IsTimestamp = true, IsLocalTime = false }
//optional DateTime theDateTime = CustomDateTimeFormat(msg.Date + " " + msg.Time);
optional DateTime theDateTime = (msg.Date + " " + msg.Time).ToDateTime();
if(theDateTime == nothing)
return CustomDateTimeFormat("01/07/1968 12:34:56.987+500") as DateTime;
else
return theDateTime as DateTime;
message SCCMLine with
EntryInfo {
Regex = @"^<!\[LOG\[(?<Message>.*)\]LOG]!><time=""(?<Time>.{16})"" date=""(?<Date>.{10})""\scomponent=""(?<Component>.*)""\scontext=""(?<Context>.*)""\stype=""(?<Type>.*)""\sthread=""(?<ThreadId>.*)""\sfile=""(?<File>.*):(?<LineNumber>.+)"">"//,
Tag = "]LOG]"
: LogEntry
string Time;
string Date;
Hopefully this helps,
Paul -
Getting Date from a Unix format Timestamp
Hi there,
I am having trouble with a WebService i am using to get some information. When i get it, the date of the different data i receive is a timestamp like 1198113192912. This number contains the milliseconds passed since the 1st of January, 1970.
The thing is that i have been looking for a MF that allows me to get the date in a readable format, but it seems that the timestamps used in SAP are slightly different, and thus, useless for me.
I would appreciate it a lot if anyone could help me out with this issue, since i do really need to have this sorted out quite soon.
Thanks in advance
Diego
Edited by: di die on Jan 25, 2008 9:41 AMHi there,
I am having trouble with a WebService i am using to get some information. When i get it, the date of the different data i receive is a timestamp like 1198113192912. This number contains the milliseconds passed since the 1st of January, 1970.
The thing is that i have been looking for a MF that allows me to get the date in a readable format, but it seems that the timestamps used in SAP are slightly different, and thus, useless for me.
I would appreciate it a lot if anyone could help me out with this issue, since i do really need to have this sorted out quite soon.
Thanks in advance
Diego
Edited by: di die on Jan 25, 2008 9:41 AM -
How to Convert Varchar2 to Date format(Timestamp)
I have a date saved in varchar2 column.
how can I convert the values into date(including Time stamp), so I can use the date to compare data.
Ex: I have the value '20-03-2007 05:31:29', but this value is saved as varchar2.
how can I take from this value the date '20-03-2007 05:31:29' as date format because later i need that date completely to add days, hours and minutes?SQL> create table dd (a varchar2(15));
Table created.
SQL>
SQL>
SQL> insert into dd values (sysdate);
1 row created.
SQL> insert into dd values (sysdate);
1 row created.
SQL> insert into dd values (sysdate);
1 row created.
SQL> insert into dd values (sysdate);
1 row created.
SQL> insert into dd values (sysdate);
1 row created.
SQL> insert into dd values (sysdate);
1 row created.
SQL>
SQL> commit;
Commit complete.
SQL>
SQL> select * from dd;
A
01-OCT-12
01-OCT-12
01-OCT-12
01-OCT-12
01-OCT-12
01-OCT-12
6 rows selected.
SQL>
SQL>
SQL> select to_date(a,'dd-mon-yyyy') from dd;
TO_DATE(A
01-OCT-12
01-OCT-12
01-OCT-12
01-OCT-12
01-OCT-12
01-OCT-12
6 rows selected.
SQL> select to_timestamp(to_date(a,'dd-mon-yyyy'),'dd mon yy hh24.mi.ss' ) from dd;
TO_TIMESTAMP(TO_DATE(A,'DD-MON-YYYY'),'DDMONYYHH24.MI.SS')
01-OCT-12 12.00.00 AM
01-OCT-12 12.00.00 AM
01-OCT-12 12.00.00 AM
01-OCT-12 12.00.00 AM
01-OCT-12 12.00.00 AM
01-OCT-12 12.00.00 AM
6 rows selected.
SQL>
that's it...... -
Pick up Files based on Timestamp???.
HI All,
Is it possible to pick up the files in the order of which they are put in a shared folder ?.
Our client system will put the xml files in a shared folder with timestamps..PI will pick these files one by one..but if the PI server is down.. the files will keep coming in the shared folder from the client system..and when PI come back up they need to be picked in the order in which they have been put according to timestamp.
I'am using the NFS functionality.
I dont want to output files from PI based on timestamp added.. I want to pick files up based upon sender timestamp.
Is this funcationality supported in PI?.
Thanks.HI
You can write script to do this. Script can copy files based on time stamp from the folder where client system is putting the file to the folder PI is poling based on timestamp.
With this as Ratan said. If the file creation date for file system is in date and time format(timestamp) File processing sequence by Date can help. It process file starting from oldest file.
Thanks
Gaurav -
SQL Developer 3.2 - Exporting data with TIMESTAMP datatype
Hi,
We have users that are attempting to export data with the Timestamp format to Excel (xls format) using SQL Developer 3.2. When attempting to sort the Timestamp in either asc or desc order, Excel is having issues sorting correctly. I suggested that the user just do all the sorting within their SQL Developer session but they require the ability to slice and dice in Excel.
This is definitely not an issue with Excel as the users have previously exported Timestamp data from Toad and been able to sort without issue. Any thoughts as to what might resolve this issue?
Thanks.We're not formatting timestamps in Oracle as numbers/dates in Excel. They'll need to properly format the Excel column/cells to get it to sort the way they want vs being treated as simple strings.
-
Hi everyone.
I have a csv file with first Column is time stamp. but i can't read in labview because Labview don't support.
The information as the attachment. Please help me read value in the first Column to time as red area on Fx.
Thanks and Best RegardsTry scanning your string like this. There's a bug where the Scan From String doesn't like to pick up the fractional seconds in a specificly formatted timestamp string. So I had to scan it separately and add.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Attachments:
Get Timestamp.png 17 KB -
How to use US date format on schedule?
When schedule a recurring instance and I'm prompted for the Start and End dates, they are formatted in the European date format.
How can I have it default to and always use the US date format?This fix from R2 seems to work with XI 3.0 as well:
https://websmp230.sap-ag.de/sap(bD1lbiZjPTAwMQ==)/bc/bsp/sno/ui/main.do?iv_mode=003&iv_sapnotes_number=1196530
Here are the steps:
Open the Last Login for User report in InfoView which requires the change.
Add a new variable in the Web Intelligence report.
Use the following function in the formula for the new variable. The function uses central time as an example:
RelativeDate([GMT format timestamp];0.25)
For example, if it is required to change to central time, use 0.25 as there is a six-hour difference between it and Greenwich Mean Time (6/24 GMT = 0.25).
Use this variable in the report to return the correct local time.
Only problem is you have to edit each auditor report and change and create another variable for any object with a "date" data type. -
BUGREPORT: Timestamp issue when creating new url mappings
We have come accross and issue when adding multiple databases and subsiqent url mappings.
the issue presented in the log is
####<Nov 16, 2012 10:49:52 AM CST> <Error> <HTTP> <adeoraapp03.santos.com> <WLS_APEX> <[ACTIVE] ExecuteThread: '0' for queue: 'weblogic.kernel.Default (self-tuning)'> <<WLS Kernel>> <> <> <1353025192413> <BEA-101020> <[ServletContext@955221946[app:apex module:apex.war path:/apex spec-version:2.5]] Servlet failed with Exception
java.lang.IllegalArgumentException: Not a correctly formatted timestamp: 2012-11-15T23:52:58.0080Z
at oracle.dbtools.common.util.Timestamps.valueOf(Timestamps.java:61)
at oracle.dbtools.common.config.db.UrlMappings$Builder$1PoolFilter.startElement(UrlMappings.java:199)
at oracle.dbtools.common.x3p.MatchFilter.startElement(MatchFilter.java:54)
at oracle.dbtools.common.x3p.impl.Event.invoke(Event.java:52)
at oracle.dbtools.common.x3p.impl.Chain$EventIterator.advance(Chain.java:125)
at oracle.dbtools.common.x3p.impl.Chain$EventIterator.advance(Chain.java:79)
at oracle.dbtools.common.util.AbstractIterator.next(AbstractIterator.java:28)
at oracle.dbtools.common.x3p.impl.X3PReaderAdaptor.next(X3PReaderAdaptor.java:34)
at oracle.dbtools.common.config.db.UrlMappings$Builder.read(UrlMappings.java:170)
at oracle.dbtools.common.config.db.UrlMappings.existing(UrlMappings.java:99)
at oracle.dbtools.common.config.db.UrlMappings.urlMappings(UrlMappings.java:93)
at oracle.dbtools.common.config.db.DatabasePoolConfig.loadFromXML(DatabasePoolConfig.java:285)
at oracle.dbtools.common.config.db.DatabasePoolConfig.loadFromDBFromTime(DatabasePoolConfig.java:181)
at oracle.dbtools.common.config.db.DatabasePoolConfig.getPoolInfo(DatabasePoolConfig.java:54)
at oracle.dbtools.rt.jdbc.DatabaseConnectionFilter.poolInfo(DatabaseConnectionFilter.java:60)
at oracle.dbtools.rt.jdbc.DatabaseConnectionFilter.applyDatabaseConnectionInfo(DatabaseConnectionFilter.java:71)
at oracle.dbtools.rt.web.HttpEndpointBase.service(HttpEndpointBase.java:119)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)
at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:301)
at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:184)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3732)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)
>
This seems to be due to a time format issue when adding new database mapping in the url-mappings
when running the following command
@:as11g_pfrd_prod> java -jar apex.war map-url --type base-path /apexpoc apexpoc
Nov 16, 2012 10:22:57 AM oracle.dbtools.common.config.file.ConfigurationFolder logConfigFolder
INFO: Using configuration folder: /data1/software/oracle/product/as11g_pfrd_prod/user_projects/domains/PFRD_Domain/servers/WLS_APEX/apex_config/apex
@:as11g_pfrd_prod> pwd
/data1/software/oracle/product/as11g_pfrd_prod/user_projects/domains/PFRD_Domain/servers/WLS_APEX/stage/apex
After running the command the following entry was added to url mappings file
This resulted in the following entries in url-mapping.xml, (the timestamps are in to be in UTC):
<pool base-path="/apexpoc" name="apexpoc" updated="2012-11-15T23:52:58.0080Z"/>
Which caused the above stack trace and also caused a internal error 500 on the browser when trying to access APEX
we removed the url mapping and ran the following command(at a different time in the day)
@:as11g_pfrd_prod> pwd
/data1/software/oracle/product/as11g_pfrd_prod/user_projects/domains/PFRD_Domain/servers/WLS_APEX/stage/apex
@:as11g_pfrd_prod> java -jar apex.war map-url --type base-path /apexpoc apexpoc
Nov 16, 2012 10:58:35 AM oracle.dbtools.common.config.file.ConfigurationFolder logConfigFolder
INFO: Using configuration folder: /data1/software/oracle/product/as11g_pfrd_prod/user_projects/domains/PFRD_Domain/servers/WLS_APEX/apex_config/apex
which resulted in a new entry in the url mappings table
<pool base-path="/apexpoc" name="apexpoc" updated="2012-11-16T00:28:35.479Z"/>
And the apex listener worked againThanks Colm,
Was this a known issue? If so do we have a common "thread" for known issues?
And do we have any idea when 2.0 Final is coming out? -
How to convert Timestamp into exact Date and Time(FM)
Hi Gurus,
could anyone tel me ,
e.g:20.11.2008:11:23:54am
How to convert Time stamp into exact Date and TimeHi,
Following is one way of doing it
Timestamp timeStamp = new Timestamp(Calendar.getInstance().getTimeInMillis());
System.out.println(timeStamp);
SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy");
System.out.println(dateFormat.format(timeStamp));
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
System.out.println(timeFormat.format(timeStamp));
Output
2008-11-20 11:59:35.693 -> Timestamp
11/20/2008
11:59:35
Regards
Ayyapparaj -
Can you control format when setting variable from dashboard prompt?
I'm setting a session variable from a calendar date prompt in a dashboard prompt, and the variable is referenced in a calculation in the business model. I'm initializing the date prompt from another variable which returns format TIMESTAMP 'YYYY-MM-DD 00:00:00', and the initial load of the dashboard is successful. After changing the value of the date prompt, the query fails because the prompt sets the variable to 'mm/dd/yyyy'.
My question is: Is there any way to control the formatting when setting a variable from a dashboard prompt? I would like to get the timestamp format.
Thanks,
GregIf You wants time than in dashboard prompt's coloumn formula use cast function as "cast(date as time)" if date than "cast(date_col_name as date)". But I also have that one problem.Firstly tell me, Is it possible that using two dates in using betwwen operator in dashboard. We access server variable. If not working one thing more that u should have filter on date coloumn in report layout.And in action coloumn u select prompted. Than It will must work.
Thanks
Haroon -
Hi,
The fields timestamp is generated seemed ith 'oracle.sql.TIMESTAMP@1ca2c4b'.
The same error occur with lob fields.
Somebody knows as to make so that they are exported in the normal format timestamp?Do not know about toad but raptor may have some issues with such columns since it is still beta.
I do now know what problem you are trying to solve, but for general export needs, you can use the import/export tools from Oracle.
C:\>exp help=y
Export: Release 10.2.0.1.0 - Production on Wed Feb 8 15:48:50 2006
Copyright (c) 1982, 2005, Oracle. All rights reserved.
You can let Export prompt you for parameters by entering the EXP
command followed by your username/password:
Example: EXP SCOTT/TIGER
Or, you can control how Export runs by entering the EXP command followed
by various arguments. To specify parameters, you use keywords:
Format: EXP KEYWORD=value or KEYWORD=(value1,value2,...,valueN)
Example: EXP SCOTT/TIGER GRANTS=Y TABLES=(EMP,DEPT,MGR)
or TABLES=(T1:P1,T1:P2), if T1 is partitioned table
USERID must be the first parameter on the command line.
Keyword Description (Default) Keyword Description (Default)
USERID username/password FULL export entire file (N)
BUFFER size of data buffer OWNER list of owner usernames
FILE output files (EXPDAT.DMP) TABLES list of table names
COMPRESS import into one extent (Y) RECORDLENGTH length of IO record
GRANTS export grants (Y) INCTYPE incremental export type
INDEXES export indexes (Y) RECORD track incr. export (Y)
DIRECT direct path (N) TRIGGERS export triggers (Y)
LOG log file of screen output STATISTICS analyze objects (ESTIMATE)
ROWS export data rows (Y) PARFILE parameter filename
CONSISTENT cross-table consistency(N) CONSTRAINTS export constraints (Y)
OBJECT_CONSISTENT transaction set to read only during object export (N)
FEEDBACK display progress every x rows (0)
FILESIZE maximum size of each dump file
FLASHBACK_SCN SCN used to set session snapshot back to
FLASHBACK_TIME time used to get the SCN closest to the specified time
QUERY select clause used to export a subset of a table
RESUMABLE suspend when a space related error is encountered(N)
RESUMABLE_NAME text string used to identify resumable statement
RESUMABLE_TIMEOUT wait time for RESUMABLE
TTS_FULL_CHECK perform full or partial dependency check for TTS
TABLESPACES list of tablespaces to export
TRANSPORT_TABLESPACE export transportable tablespace metadata (N)
TEMPLATE template name which invokes iAS mode export
Export terminated successfully without warnings.
C:\> -
Is there an easy way to filter a 2-d array based on the values of two of the fields?
Is there an easy way to filter a 2-d array based on the values of one of the fields. In my attached VI the output array has the following format:
TimeStamp Ident Frame Type Bytes Data
10:57:07.621 3AD00016 CAN Data Frame 8 0000000000000000
10:57:07.622 3AD00017 CAN Data Frame 8 000005E000000000
10:57:07.624 3AD00018 CAN Data Frame 8 0000000003300000
10:57:07.625 2DC00000 CAN Data Frame 8 0000000000000000
10:57:07.626 3AD00019 CAN Data Frame 4 0000030000000000
I would like to delete any rows that do not have an "Ident" between the values of 3AD00000 and 3AD0001E. So for the above data the fourth row would be deleted. The only way I can see to do it is to form a 1-d array. Is there a better approach?
Thank you.
Solved!
Go to Solution.
Attachments:
CMM_SN_MULTI.vi 20 KBHi chuck72352,
after you have sorted your data, you can use the InRange Function. Combined with a "search 1D Array" you'll get the range you really want.
Mike
Attachments:
ArraySubset.PNG 25 KB -
Multiple While Loops Write to One File
Hello,
I have three different instruments from which I am sampling, each at a
different sampling rate. Each instrument is being sampled in its
own While loop. How do I write all the samples I collect to a
single text file? I would like something in the following format:
[Timestamp] [Instrument 1's First Sample] [Instrument 2's First Sample] [Instrument 3's First Sample]
[Timestamp] [Instrument 1's Second Sample] [Instrument 2's Second Sample] [Instrument 3's Second Sample]
...and so on..
Thank you,
Olyviaofro wrote:
I have three different instruments from which I am sampling, each at a different sampling rate. Each instrument is being sampled in its own While loop. How do I write all the samples I collect to a single text file? I would like something in the following format:
[Timestamp] [Instrument 1's First Sample] [Instrument 2's First Sample] [Instrument 3's First Sample]
[Timestamp] [Instrument 1's Second Sample] [Instrument 2's Second Sample] [Instrument 3's Second Sample]
...and so on..
This seems like a flawed project.
If each loop samples at a different rate, the samples will arrive at different times. Typically there won't be a single timestamp for all three samples. Can you explain what you actually want to write to the file from each loop?
Do you want to write to the file incrementally inside each loop, or do you want to write everything at once after all loops have finished?
LabVIEW Champion . Do more with less code and in less time . -
List "View" with current time in column
Hi.
I know that list view does not support fields calculated on page load. But I have to realize such functionality.
Can someone provide options for realizing this?
"Hack" some internal SQL query, inject JS on a view page, use .NET code somehow?
Using JS seems as the best solution, but how can I do this?
Thanks.Hi,
According to your post, my understanding is that you wanted to display the current time in colum.
The following code snippet for your reference.
<script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
function date(format, timestamp) {
var that = this,
jsdate, f, formatChr = /\\?([a-z])/gi,
formatChrCb,
// Keep this here (works, but for code commented-out
// below for file size reasons)
//, tal= [],
_pad = function(n, c) {
n = n.toString();
return n.length < c ? _pad('0' + n, c, '0') : n;
txt_words = ["Sun", "Mon", "Tues", "Wednes", "Thurs", "Fri", "Satur", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
formatChrCb = function(t, s) {
return f[t] ? f[t]() : s;
f = {
// Day
d: function() { // Day of month w/leading 0; 01..31
return _pad(f.j(), 2);
D: function() { // Shorthand day name; Mon...Sun
return f.l().slice(0, 3);
j: function() { // Day of month; 1..31
return jsdate.getDate();
l: function() { // Full day name; Monday...Sunday
return txt_words[f.w()] + 'day';
N: function() { // ISO-8601 day of week; 1[Mon]..7[Sun]
return f.w() || 7;
S: function() { // Ordinal suffix for day of month; st, nd, rd, th
var j = f.j();
if (j < 4 || j > 20) {
return (['st', 'nd', 'rd'])[j % 10 - 1];
else {
return 'th';
w: function() { // Day of week; 0[Sun]..6[Sat]
return jsdate.getDay();
z: function() { // Day of year; 0..365
var a = new Date(f.Y(), f.n() - 1, f.j()),
b = new Date(f.Y(), 0, 1);
return Math.round((a - b) / 864e5);
// Week
W: function() { // ISO-8601 week number
var a = new Date(f.Y(), f.n() - 1, f.j() - f.N() + 3),
b = new Date(a.getFullYear(), 0, 4);
return _pad(1 + Math.round((a - b) / 864e5 / 7), 2);
// Month
F: function() { // Full month name; January...December
return txt_words[6 + f.n()];
m: function() { // Month w/leading 0; 01...12
return _pad(f.n(), 2);
M: function() { // Shorthand month name; Jan...Dec
return f.F().slice(0, 3);
n: function() { // Month; 1...12
return jsdate.getMonth() + 1;
t: function() { // Days in month; 28...31
return (new Date(f.Y(), f.n(), 0)).getDate();
// Year
L: function() { // Is leap year?; 0 or 1
var j = f.Y();
return j % 4 === 0 & j % 100 !== 0 | j % 400 === 0;
o: function() { // ISO-8601 year
var n = f.n(),
W = f.W(),
Y = f.Y();
return Y + (n === 12 && W < 9 ? 1 : n === 1 && W > 9 ? -1 : 0);
Y: function() { // Full year; e.g. 1980...2010
return jsdate.getFullYear();
y: function() { // Last two digits of year; 00...99
return f.Y().toString().slice(-2);
// Time
a: function() { // am or pm
return jsdate.getHours() > 11 ? "pm" : "am";
A: function() { // AM or PM
return f.a().toUpperCase();
B: function() { // Swatch Internet time; 000..999
var H = jsdate.getUTCHours() * 36e2,
// Hours
i = jsdate.getUTCMinutes() * 60,
// Minutes
s = jsdate.getUTCSeconds(); // Seconds
return _pad(Math.floor((H + i + s + 36e2) / 86.4) % 1e3, 3);
g: function() { // 12-Hours; 1..12
return f.G() % 12 || 12;
G: function() { // 24-Hours; 0..23
return jsdate.getHours();
h: function() { // 12-Hours w/leading 0; 01..12
return _pad(f.g(), 2);
H: function() { // 24-Hours w/leading 0; 00..23
return _pad(f.G(), 2);
i: function() { // Minutes w/leading 0; 00..59
return _pad(jsdate.getMinutes(), 2);
s: function() { // Seconds w/leading 0; 00..59
return _pad(jsdate.getSeconds(), 2);
u: function() { // Microseconds; 000000-999000
return _pad(jsdate.getMilliseconds() * 1000, 6);
// Timezone
e: function() { // Timezone identifier; e.g. Atlantic/Azores, ...
// The following works, but requires inclusion of the very large
// timezone_abbreviations_list() function.
/* return that.date_default_timezone_get();
throw 'Not supported (see source code of date() for timezone on how to add support)';
I: function() { // DST observed?; 0 or 1
// Compares Jan 1 minus Jan 1 UTC to Jul 1 minus Jul 1 UTC.
// If they are not equal, then DST is observed.
var a = new Date(f.Y(), 0),
// Jan 1
c = Date.UTC(f.Y(), 0),
// Jan 1 UTC
b = new Date(f.Y(), 6),
// Jul 1
d = Date.UTC(f.Y(), 6); // Jul 1 UTC
return ((a - c) !== (b - d)) ? 1 : 0;
O: function() { // Difference to GMT in hour format; e.g. +0200
var tzo = jsdate.getTimezoneOffset(),
a = Math.abs(tzo);
return (tzo > 0 ? "-" : "+") + _pad(Math.floor(a / 60) * 100 + a % 60, 4);
P: function() { // Difference to GMT w/colon; e.g. +02:00
var O = f.O();
return (O.substr(0, 3) + ":" + O.substr(3, 2));
T: function() { // Timezone abbreviation; e.g. EST, MDT, ...
// The following works, but requires inclusion of the very
// large timezone_abbreviations_list() function.
/* var abbr = '', i = 0, os = 0, default = 0;
if (!tal.length) {
tal = that.timezone_abbreviations_list();
if (that.php_js && that.php_js.default_timezone) {
default = that.php_js.default_timezone;
for (abbr in tal) {
for (i=0; i < tal[abbr].length; i++) {
if (tal[abbr][i].timezone_id === default) {
return abbr.toUpperCase();
for (abbr in tal) {
for (i = 0; i < tal[abbr].length; i++) {
os = -jsdate.getTimezoneOffset() * 60;
if (tal[abbr][i].offset === os) {
return abbr.toUpperCase();
return 'UTC';
Z: function() { // Timezone offset in seconds (-43200...50400)
return -jsdate.getTimezoneOffset() * 60;
// Full Date/Time
c: function() { // ISO-8601 date.
return 'Y-m-d\\TH:i:sP'.replace(formatChr, formatChrCb);
r: function() { // RFC 2822
return 'D, d M Y H:i:s O'.replace(formatChr, formatChrCb);
U: function() { // Seconds since UNIX epoch
return jsdate / 1000 | 0;
this.date = function(format, timestamp) {
that = this;
jsdate = (timestamp === undefined ? new Date() : // Not provided
(timestamp instanceof Date) ? new Date(timestamp) : // JS Date()
new Date(timestamp * 1000) // UNIX timestamp (auto-convert to int)
return format.replace(formatChr, formatChrCb);
return this.date(format, timestamp);
$(function() {
$('.ms-noWrap').text(date('l, F jS, Y, h:i:s A'));
</script>
Note: You should change the class name to fit your environment.
http://jsfiddle.net/licson0729/jHHsm/
More reference:
http://social.technet.microsoft.com/Forums/sharepoint/en-US/580b9c50-f945-4931-b68f-da68d84e766e/how-to-display-current-date-time-in-share-point-using-jquery
Thanks & Regards,
Jason
Jason Guo
TechNet Community Support
Maybe you are looking for
-
Deploying JSC Web App to SJSAS9
Hi there, I have several web applications I've written in Netbeans, and they run on a SJSAS9 server. I've also written a JSC web app, and I would now like to deploy this onto the same SJSAS9 server that I've got my other web apps on. It is certainly
-
How do I CANCEL a Remote Lock request made on iCloud?
How do I Cancel a Remote Lock Request I made on iCloud?
-
I need some serious help with MPEG Streamclip and iMovie 11
Hello, everyone! I hope that some kind soul here is able to help me. My sister-in-law asked me if I could help her re-edit a video that they made of a conference she gave because she didn't like the way some parts were edited. I oh-so-kindly (and per
-
The company that I'm doing some work for wants to use SABA as the delivery LMS for the E-Learning packages I'm about to embark on creating. If anyone has any experience with SABA & captivate could you let me know if there are any problems with SCORM
-
Could not sign in. There was a problem connecting to the server.
The top button on my iphone broke. So the apple shop have given me a new iphone and when i have gone to restore from icloud i accept the terms and conditions and it says 'it may take a few minutes to set up your apple ID' then 'could not sign in. the