Comments (7)
Also the date function syntax:
http://au.php.net/manual/en/function.date.php
I think it is really important to get a universal thing going on.
Original comment by [email protected]
on 20 Mar 2008 at 12:38
from datejs.
I've come up with the following as a temporary solution.
Original comment by [email protected]
on 20 Mar 2008 at 1:29
Attachments:
from datejs.
@balupton - ok, A while back I also played with this same concept of just
converting
the PHP/Unix date format into a Java/.NET date format. Your persistence got me
thinking again and I've reconsidered adding the functionality into the library.
The
conversion function probably will not make it into the core library, but I will
add
to an optional "extras.js" module.
Original comment by geoff%[email protected]
on 26 Mar 2008 at 5:42
- Changed state: Started
from datejs.
Ok awesome, problem is that the PHP date/strftime also have a lot more things
than
Date.toString, so will you be working on adding that, or just make a conversion
function?
And thanks a bunch!
Original comment by [email protected]
on 27 Mar 2008 at 1:58
from datejs.
@balupton - I added a new extras.js module that includes a the .format()
function
which takes a Unix/PHP date format string as a parameter.
The .format() function supports all the format specifiers. Each format
specifier is
listed in the FormatSpecifiers wiki documentation. See
http://code.google.com/p/datejs/wiki/FormatSpecifiers
I also added a Date.normalizeFormat() function which will converts a PHP format
string to Java/.NET format string. A PHP format string can be used with
.$format or
.format. A Java/.NET format string can be used with .toString(). The .parseExact
function will only accept a Java/.NET format string
Example
Date.normalizeFormat("%m/%d/%y"); // "MM/dd/yy"
var f1 = "%m/%d/%y"
var f2 = Date.normalizeFormat(f1); // "MM/dd/yy"
new Date().format(f1); // "04/13/08"
new Date().$format(f1); // "04/13/08"
new Date().toString(f2); // "04/13/08"
var date = Date.parseExact("04/13/08", f2); // Sun Apr 13 2008
I also added .strftime() which will format a local Unix timestamp according to
locale
settings.
Example
Date.strftime("%m/%d/%y", new Date()); // "04/13/08"
Date.strftime("c", "2008-04-13T17:52:03Z"); // "04/13/08"
I also added .strtotime() which will parse any textual datetime description
into a
Unix timestamp. A Unix timestamp is the number of seconds that have elapsed
since
January 1, 1970 (midnight UTC/GMT).
Example
Date.strtotime("04/13/08"); // 1208044800
Date.strtotime("1970-01-01T00:00:00Z"); // 0
More information is available in the CHANGELOG
(http://www.datejs.com/changelog).
The extras.js file is available in SVN at the following location
(http://www.datejs.com/svn/extras/).
Hope this helps.
Original comment by geoff%[email protected]
on 14 Apr 2008 at 5:22
- Changed title: [FIXED] Date().toString() support for PHP's strftime
- Changed state: Fixed
from datejs.
Ok great. Although I'm a bit confused over what files I should be including?
Should I include core.js date-en-AU.js and extras.js ? And how would I go about
merging all of these into one packed file?
Original comment by [email protected]
on 17 May 2008 at 12:40
from datejs.
Just include the appropriate culture-specific file (date-en-AU.js) and then
extras.js.
Example
<script type="text/javascript" src="date-en-AU.js"></script>
<script type="text/javascript" src="extras.js"></script>
The culture-specific file (date-en-US.js) already includes core.js.
Each culture-specific file is made of the following:
1. A CultureInfo file (this is culture specific)
2. core.js
3. parser.js
4. sugarpak.js
A compressed version of extras.js is provided in the /build/ folder. Probably
the
easiest thing to do to merge extras.js into date-en-AU.js would be to
copy/paste the
contents of the /build/extras.js into the end of /build/date-en-AU.js.
Hope this helps.
Original comment by geoff%[email protected]
on 17 May 2008 at 8:47
from datejs.
Related Issues (20)
- Date.parse() on RFC 3339 Format Date Time yields a null object in IE 10 only
- Date.parse("2011-W12") does not work
- add functions not working at daylight savings boundary
- Uncaught TypeError: Object [object Date] has no method 'getISOWeek' HOT 1
- fa-IR jalali shamsi support is not working
- Add quarter to format strings HOT 1
- it-IT.js error in date format . instead of : H.mm instead of H:mm HOT 2
- Date.parse() seems to mix up day and month HOT 1
- add().days().toString() returns different dates depending on format chosen
- parsing fail for date '1997-07-16T19:20:30+01:00', '1985-04-12T23:20:50Z'
- Date.getTimezoneAbbreviation is wrong
- Patch for /trunk/src/globalization/id-ID.js
- when you do var dt2=dt1.next().sunday(), dt1 itself changes to next sunday
- persian months, days, first day of week, first month, ... do not set properly
- Don't clobber Date.now HOT 2
- Ortography date-es-MX.js
- .addMonths('6') != .addMonths(6). String problem
- Is datajs works on IE
- Standard Formats (single letter formats) are not working correctly HOT 1
- getTimezone returns null
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from datejs.