-
-
Save ztane/11109057 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
#Equivalent to this PHP codes: | |
$gmt_timezone = new DateTimeZone('GMT'); | |
$obj_date = new DateTime(null,$gmt_timezone); | |
echo $obj_date->format('d/m/Y h:i:s'); | |
#OR | |
date_default_timezone_set("GMT"); | |
echo date('d/m/Y h:i:s', time()); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from datetime import datetime | |
from dateutil import parser | |
now = datetime.now() | |
current_year = now.year | |
current_month = now.month | |
curren_day = now.day | |
print '%s/%s/%s' % (now.day, now.month, now.year) #2014-4-5 | |
print '%s:%s:%s' % (now.hour, now.minute, now.second) #19:30:1 | |
print '%s/%s/%s %s:%s:%s' % (now.day, now.month, now.year, now.hour, now.minute, now.second) #5/4/2014 19:32:2 | |
dt = parser.parse("Aug 28 1999 12:00AM") | |
print dt | |
print datetime.now().strftime('%Y-%m-%d %H:%M:%S') | |
date1 = datetime(2009, 12, 31, 12, 0, 0); | |
print date1.strftime("%d-%m-%Y %H:%M:%S") | |
date_object = datetime.strptime('Jun 1 2005 1:33PM', '%b %d %Y %I:%M%p') | |
print date_object |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#http://www.tutorialspoint.com/ruby/ruby_date_time.htm | |
#!/usr/bin/ruby | |
time = Time.new | |
puts time.to_s | |
puts time.ctime | |
puts time.localtime | |
puts time.strftime("%d/%m/%Y %H:%M:%S") | |
# July 8, 2008 | |
Time.local(2008, 7, 8) | |
# July 8, 2008, 09:10am, local time | |
Time.local(2008, 7, 8, 9, 10) | |
# July 8, 2008, 09:10 UTC | |
Time.utc(2008, 7, 8, 9, 10) | |
# July 8, 2008, 09:10:11 GMT (same as UTC) | |
Time.gm(2008, 7, 8, 9, 10, 11) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment